{"action":"created","comment":{"url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/pulls/comments/28474757","id":28474757,"diff_hunk":"@@ -0,0 +1,103 @@\n+import scrapy\n+from scrapy import Selector\n+from scrapy.contrib.loader import ItemLoader\n+from scrapy.contrib.loader.processor import Join, MapCompose\n+import re\n+\n+from gma_videos.items import GmaVideosItem\n+\n+#filename for url list text file\n+URL_LIST = './keywords_and_urls/traffic_urls'\n+\n+#filename for location keywords text file\n+LOCATION_KEYWORDS = './keywords_and_urls/location_keywords'\n+\n+def location_from_articles(s):\n+\twith open(LOCATION_KEYWORDS, 'r') as file:\n+\t\tlocation_keywords = file.read().splitlines()\n+\n+\tlocation_keywords = [x.strip().lower() for x in location_keywords]\n+\tlocation_keywords = set(location_keywords)\n+\tif '' in location_keywords:\n+\t\tlocation_keywords.remove('')\n+\tlocation_keywords = [x + ' ' for x in location_keywords]\n+\n+\tloc_tag = []\n+\n+\tfor location in location_keywords:\n+\t\tif location in s.lower():\n+\t\t\tlocation = location.strip()\n+\t\t\tloc_tag.append(location)\n+\n+\t# to remove false matches of Quezon Province to the article\n+\tif 'quezon' in loc_tag:\n+\t\tquezon_count = len(re.findall(r'quezon', s.lower()))\n+\t\tquezon_city_count = len(re.findall(r'quezon_city', s.lower()))\n+\n+\t\tif quezon_city_count == quezon_count:\n+\t\t\tloc_tag.remove('quezon')\n+\n+\treturn loc_tag\n+\n+def ascii_or_remove(s):\n+\treturn s.encode('ascii', errors='ignore')\n+\n+def open_url_file():\n+\twith open(URL_LIST, 'r') as file:\n+\t\turls_list = file.read().splitlines\n+\n+\treturn urls_list\n+\n+class ArticleLoader(ItemLoader):\n+\tdefault_input_processor = MapCompose(unicode.strip, ascii_or_remove)\n+\tdefault_output_processor = Join()\n+\n+\tlocation_in = MapCompose(unicode.strip, ascii_or_remove, location_from_articles)\n+\tlocation_out = Join(', ')\n+\n+class GmaVideoSpider(scrapy.Spider):\n+\tname = 'gma_video_spider'\n+\tallowed_domains = ['gmanetwork.com']\n+\n+\tstart_urls = open_url_file()\n+\n+\tdef parse(self, response):\n+\t\t\"\"\"\n+\t\tDefault callback Scrapy uses to process download\n+\t\t\"\"\"\n+\t\tsel = Selector(response)\n+\t\tloader = ArticleLoader(item=GmaVideosItem(),selector=sel)\n+\n+\t\tyield loader.loader_item()\n+\n+","path":"gma_videos/gma_videos/spiders/gma_video_spider.py","position":73,"original_position":73,"commit_id":"40cef44beb627eee8ae564309f04c663b86c97ff","original_commit_id":"40cef44beb627eee8ae564309f04c663b86c97ff","user":{"login":"antoniocarlosortiz","id":7996579,"avatar_url":"https://avatars.githubusercontent.com/u/7996579?v=3","gravatar_id":"","url":"https://api.github.com/users/antoniocarlosortiz","html_url":"https://github.com/antoniocarlosortiz","followers_url":"https://api.github.com/users/antoniocarlosortiz/followers","following_url":"https://api.github.com/users/antoniocarlosortiz/following{/other_user}","gists_url":"https://api.github.com/users/antoniocarlosortiz/gists{/gist_id}","starred_url":"https://api.github.com/users/antoniocarlosortiz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antoniocarlosortiz/subscriptions","organizations_url":"https://api.github.com/users/antoniocarlosortiz/orgs","repos_url":"https://api.github.com/users/antoniocarlosortiz/repos","events_url":"https://api.github.com/users/antoniocarlosortiz/events{/privacy}","received_events_url":"https://api.github.com/users/antoniocarlosortiz/received_events","type":"User","site_admin":false},"body":"thanks!","created_at":"2015-04-16T00:02:27Z","updated_at":"2015-04-16T00:02:27Z","html_url":"https://github.com/SiliconValleyInsight/in-the-news/pull/7#discussion_r28474757","pull_request_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/pulls/comments/28474757"},"html":{"href":"https://github.com/SiliconValleyInsight/in-the-news/pull/7#discussion_r28474757"},"pull_request":{"href":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/pulls/7","id":33360256,"html_url":"https://github.com/SiliconValleyInsight/in-the-news/pull/7","diff_url":"https://github.com/SiliconValleyInsight/in-the-news/pull/7.diff","patch_url":"https://github.com/SiliconValleyInsight/in-the-news/pull/7.patch","issue_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/issues/7","number":7,"state":"open","locked":false,"title":"Bug fixes and optimization","user":{"login":"antoniocarlosortiz","id":7996579,"avatar_url":"https://avatars.githubusercontent.com/u/7996579?v=3","gravatar_id":"","url":"https://api.github.com/users/antoniocarlosortiz","html_url":"https://github.com/antoniocarlosortiz","followers_url":"https://api.github.com/users/antoniocarlosortiz/followers","following_url":"https://api.github.com/users/antoniocarlosortiz/following{/other_user}","gists_url":"https://api.github.com/users/antoniocarlosortiz/gists{/gist_id}","starred_url":"https://api.github.com/users/antoniocarlosortiz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antoniocarlosortiz/subscriptions","organizations_url":"https://api.github.com/users/antoniocarlosortiz/orgs","repos_url":"https://api.github.com/users/antoniocarlosortiz/repos","events_url":"https://api.github.com/users/antoniocarlosortiz/events{/privacy}","received_events_url":"https://api.github.com/users/antoniocarlosortiz/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-04-15T14:31:58Z","updated_at":"2015-04-16T00:02:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7dee9dcb7c8476c434dfe5424222ef38a0ed35f5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/pulls/7/commits","review_comments_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/pulls/7/comments","review_comment_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/issues/7/comments","statuses_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/statuses/40cef44beb627eee8ae564309f04c663b86c97ff","head":{"label":"SiliconValleyInsight:bug-fixes-and-optimization","ref":"bug-fixes-and-optimization","sha":"40cef44beb627eee8ae564309f04c663b86c97ff","user":{"login":"SiliconValleyInsight","id":7948646,"avatar_url":"https://avatars.githubusercontent.com/u/7948646?v=3","gravatar_id":"","url":"https://api.github.com/users/SiliconValleyInsight","html_url":"https://github.com/SiliconValleyInsight","followers_url":"https://api.github.com/users/SiliconValleyInsight/followers","following_url":"https://api.github.com/users/SiliconValleyInsight/following{/other_user}","gists_url":"https://api.github.com/users/SiliconValleyInsight/gists{/gist_id}","starred_url":"https://api.github.com/users/SiliconValleyInsight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SiliconValleyInsight/subscriptions","organizations_url":"https://api.github.com/users/SiliconValleyInsight/orgs","repos_url":"https://api.github.com/users/SiliconValleyInsight/repos","events_url":"https://api.github.com/users/SiliconValleyInsight/events{/privacy}","received_events_url":"https://api.github.com/users/SiliconValleyInsight/received_events","type":"Organization","site_admin":false},"repo":{"id":33577229,"name":"in-the-news","full_name":"SiliconValleyInsight/in-the-news","owner":{"login":"SiliconValleyInsight","id":7948646,"avatar_url":"https://avatars.githubusercontent.com/u/7948646?v=3","gravatar_id":"","url":"https://api.github.com/users/SiliconValleyInsight","html_url":"https://github.com/SiliconValleyInsight","followers_url":"https://api.github.com/users/SiliconValleyInsight/followers","following_url":"https://api.github.com/users/SiliconValleyInsight/following{/other_user}","gists_url":"https://api.github.com/users/SiliconValleyInsight/gists{/gist_id}","starred_url":"https://api.github.com/users/SiliconValleyInsight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SiliconValleyInsight/subscriptions","organizations_url":"https://api.github.com/users/SiliconValleyInsight/orgs","repos_url":"https://api.github.com/users/SiliconValleyInsight/repos","events_url":"https://api.github.com/users/SiliconValleyInsight/events{/privacy}","received_events_url":"https://api.github.com/users/SiliconValleyInsight/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SiliconValleyInsight/in-the-news","description":"","fork":false,"url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news","forks_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/forks","keys_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/teams","hooks_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/hooks","issue_events_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/issues/events{/number}","events_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/events","assignees_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/assignees{/user}","branches_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/branches{/branch}","tags_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/tags","blobs_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/git/refs{/sha}","trees_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/statuses/{sha}","languages_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/languages","stargazers_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/stargazers","contributors_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/contributors","subscribers_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/subscribers","subscription_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/subscription","commits_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/commits{/sha}","git_commits_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/git/commits{/sha}","comments_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/comments{/number}","issue_comment_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/issues/comments{/number}","contents_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/contents/{+path}","compare_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/merges","archive_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/downloads","issues_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/issues{/number}","pulls_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/pulls{/number}","milestones_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/milestones{/number}","notifications_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/labels{/name}","releases_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/releases{/id}","created_at":"2015-04-08T01:16:29Z","updated_at":"2015-04-15T00:42:32Z","pushed_at":"2015-04-15T14:31:58Z","git_url":"git://github.com/SiliconValleyInsight/in-the-news.git","ssh_url":"git@github.com:SiliconValleyInsight/in-the-news.git","clone_url":"https://github.com/SiliconValleyInsight/in-the-news.git","svn_url":"https://github.com/SiliconValleyInsight/in-the-news","homepage":null,"size":1952,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":1,"default_branch":"master"}},"base":{"label":"SiliconValleyInsight:master","ref":"master","sha":"db25a21f0996fed98a68df9af0c5939f58ec2996","user":{"login":"SiliconValleyInsight","id":7948646,"avatar_url":"https://avatars.githubusercontent.com/u/7948646?v=3","gravatar_id":"","url":"https://api.github.com/users/SiliconValleyInsight","html_url":"https://github.com/SiliconValleyInsight","followers_url":"https://api.github.com/users/SiliconValleyInsight/followers","following_url":"https://api.github.com/users/SiliconValleyInsight/following{/other_user}","gists_url":"https://api.github.com/users/SiliconValleyInsight/gists{/gist_id}","starred_url":"https://api.github.com/users/SiliconValleyInsight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SiliconValleyInsight/subscriptions","organizations_url":"https://api.github.com/users/SiliconValleyInsight/orgs","repos_url":"https://api.github.com/users/SiliconValleyInsight/repos","events_url":"https://api.github.com/users/SiliconValleyInsight/events{/privacy}","received_events_url":"https://api.github.com/users/SiliconValleyInsight/received_events","type":"Organization","site_admin":false},"repo":{"id":33577229,"name":"in-the-news","full_name":"SiliconValleyInsight/in-the-news","owner":{"login":"SiliconValleyInsight","id":7948646,"avatar_url":"https://avatars.githubusercontent.com/u/7948646?v=3","gravatar_id":"","url":"https://api.github.com/users/SiliconValleyInsight","html_url":"https://github.com/SiliconValleyInsight","followers_url":"https://api.github.com/users/SiliconValleyInsight/followers","following_url":"https://api.github.com/users/SiliconValleyInsight/following{/other_user}","gists_url":"https://api.github.com/users/SiliconValleyInsight/gists{/gist_id}","starred_url":"https://api.github.com/users/SiliconValleyInsight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SiliconValleyInsight/subscriptions","organizations_url":"https://api.github.com/users/SiliconValleyInsight/orgs","repos_url":"https://api.github.com/users/SiliconValleyInsight/repos","events_url":"https://api.github.com/users/SiliconValleyInsight/events{/privacy}","received_events_url":"https://api.github.com/users/SiliconValleyInsight/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SiliconValleyInsight/in-the-news","description":"","fork":false,"url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news","forks_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/forks","keys_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/teams","hooks_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/hooks","issue_events_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/issues/events{/number}","events_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/events","assignees_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/assignees{/user}","branches_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/branches{/branch}","tags_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/tags","blobs_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/git/refs{/sha}","trees_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/statuses/{sha}","languages_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/languages","stargazers_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/stargazers","contributors_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/contributors","subscribers_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/subscribers","subscription_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/subscription","commits_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/commits{/sha}","git_commits_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/git/commits{/sha}","comments_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/comments{/number}","issue_comment_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/issues/comments{/number}","contents_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/contents/{+path}","compare_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/merges","archive_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/downloads","issues_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/issues{/number}","pulls_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/pulls{/number}","milestones_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/milestones{/number}","notifications_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/labels{/name}","releases_url":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/releases{/id}","created_at":"2015-04-08T01:16:29Z","updated_at":"2015-04-15T00:42:32Z","pushed_at":"2015-04-15T14:31:58Z","git_url":"git://github.com/SiliconValleyInsight/in-the-news.git","ssh_url":"git@github.com:SiliconValleyInsight/in-the-news.git","clone_url":"https://github.com/SiliconValleyInsight/in-the-news.git","svn_url":"https://github.com/SiliconValleyInsight/in-the-news","homepage":null,"size":1952,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/pulls/7"},"html":{"href":"https://github.com/SiliconValleyInsight/in-the-news/pull/7"},"issue":{"href":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/issues/7"},"comments":{"href":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/SiliconValleyInsight/in-the-news/statuses/40cef44beb627eee8ae564309f04c663b86c97ff"}}}}