{"action":"created","comment":{"url":"https://api.github.com/repos/gator-life/gator/pulls/comments/36275468","id":36275468,"diff_hunk":"@@ -40,34 +61,43 @@ def _get_invalid_regex():\n     invalid_paths_regex = re.compile('(' + '|'.join(invalid_paths) + ')')\n     return invalid_paths_regex\n \n-\n-def _dump_json_docs(docs_as_jsons, destination_folder):\n+def _dump_json_docs(docs_as_json, destination_folder):\n     current_date = datetime.datetime.utcnow()\n     current_index = 0\n-    for json_doc in docs_as_jsons:\n-        with open(destination_folder + '/' + str(current_date) + '_' + str(current_index) + '.json', 'w') as dest_file:\n+    for json_doc in docs_as_json:\n+        filename = destination_folder + '/' + str(current_date) + '_' + str(current_index) + '.json'\n+        with codecs.open(filename=filename, mode='w', encoding='utf-8') as dest_file:\n             dest_file.write(json_doc)\n         current_index += 1\n \n+\n def scrap(disconnected=False):\n     \"\"\"\n     :return: a generator of Document as json strings, can be deserialized by jsonpickle\n     \"\"\"\n     invalid_paths_regex = _get_invalid_regex()\n-    invalid_extensions = ['.jpg', '.gif', '.png']\n+    invalid_extensions = ['.jpg', '.gif', '.png', '.webm']\n     filter_func = partial(_is_valid_link, invalid_paths_regex=invalid_paths_regex, invalid_extensions=invalid_extensions)\n     links_elts = reddit_link_elements_generator(disconnected)\n     filtered_links = ifilter(filter_func, links_elts)\n-    links_and_htmls = imap(lambda link: (link, _try_get_html(link.url)), filtered_links)\n-    filtered_links_html = ifilter(lambda (link, html): html is not None, links_and_htmls)  # take successfully loaded html\n+    docs_as_jsons = _get_json_doc_generator(filtered_links)\n+    return docs_as_jsons\n+\n+\n+def _get_json_doc_generator(link_elts):\n+    jsonpickle.set_encoder_options('simplejson', indent=4, ensure_ascii=False)  # set unicode and pretty-print\n+\n+    links_and_htmls = imap(lambda link: (link, _try_get_html(link.url)), link_elts)  # take successfully loaded html\n+    filtered_links_html = ifilter(lambda (link, html): html is not None, links_and_htmls)\n     documents = starmap(Document, filtered_links_html)\n     docs_as_jsons = imap(jsonpickle.encode, documents)\n     return docs_as_jsons\n \n+\n def scrap_and_dump(destination_folder):\n     \"\"\"\n     scrap and dump one document by file\n-    :param destination_folder: folder must already exist\n+    :param destination_folde_convert_to_utf8r: folder must already exist","path":"src/scraper/scraper/scraper.py","position":107,"original_position":107,"commit_id":"c3812b868bacce31a2ce907cb4bce69356afbbf2","original_commit_id":"c3812b868bacce31a2ce907cb4bce69356afbbf2","user":{"login":"nicoxx","id":6695280,"avatar_url":"https://avatars.githubusercontent.com/u/6695280?v=3","gravatar_id":"","url":"https://api.github.com/users/nicoxx","html_url":"https://github.com/nicoxx","followers_url":"https://api.github.com/users/nicoxx/followers","following_url":"https://api.github.com/users/nicoxx/following{/other_user}","gists_url":"https://api.github.com/users/nicoxx/gists{/gist_id}","starred_url":"https://api.github.com/users/nicoxx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicoxx/subscriptions","organizations_url":"https://api.github.com/users/nicoxx/orgs","repos_url":"https://api.github.com/users/nicoxx/repos","events_url":"https://api.github.com/users/nicoxx/events{/privacy}","received_events_url":"https://api.github.com/users/nicoxx/received_events","type":"User","site_admin":false},"body":"oops, it's a typo, i will fix it","created_at":"2015-08-05T07:23:23Z","updated_at":"2015-08-05T07:23:23Z","html_url":"https://github.com/gator-life/gator/pull/10#discussion_r36275468","pull_request_url":"https://api.github.com/repos/gator-life/gator/pulls/10","_links":{"self":{"href":"https://api.github.com/repos/gator-life/gator/pulls/comments/36275468"},"html":{"href":"https://github.com/gator-life/gator/pull/10#discussion_r36275468"},"pull_request":{"href":"https://api.github.com/repos/gator-life/gator/pulls/10"}}},"pull_request":{"url":"https://api.github.com/repos/gator-life/gator/pulls/10","id":41649858,"html_url":"https://github.com/gator-life/gator/pull/10","diff_url":"https://github.com/gator-life/gator/pull/10.diff","patch_url":"https://github.com/gator-life/gator/pull/10.patch","issue_url":"https://api.github.com/repos/gator-life/gator/issues/10","number":10,"state":"open","locked":false,"title":"encode json serailization of Document and html content to utf-8","user":{"login":"nicoxx","id":6695280,"avatar_url":"https://avatars.githubusercontent.com/u/6695280?v=3","gravatar_id":"","url":"https://api.github.com/users/nicoxx","html_url":"https://github.com/nicoxx","followers_url":"https://api.github.com/users/nicoxx/followers","following_url":"https://api.github.com/users/nicoxx/following{/other_user}","gists_url":"https://api.github.com/users/nicoxx/gists{/gist_id}","starred_url":"https://api.github.com/users/nicoxx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicoxx/subscriptions","organizations_url":"https://api.github.com/users/nicoxx/orgs","repos_url":"https://api.github.com/users/nicoxx/repos","events_url":"https://api.github.com/users/nicoxx/events{/privacy}","received_events_url":"https://api.github.com/users/nicoxx/received_events","type":"User","site_admin":false},"body":"skip url if there is ambiguity in the encoding\r\nuse 'requests' instead of urllib2 as it manages encoding better, use simplejson backend for jsonpickle for the same reason","created_at":"2015-08-05T07:21:01Z","updated_at":"2015-08-05T07:23:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1c7b343b9fe56d8d7a657789319029f3a266e695","assignee":{"login":"m-mokhtari","id":11430721,"avatar_url":"https://avatars.githubusercontent.com/u/11430721?v=3","gravatar_id":"","url":"https://api.github.com/users/m-mokhtari","html_url":"https://github.com/m-mokhtari","followers_url":"https://api.github.com/users/m-mokhtari/followers","following_url":"https://api.github.com/users/m-mokhtari/following{/other_user}","gists_url":"https://api.github.com/users/m-mokhtari/gists{/gist_id}","starred_url":"https://api.github.com/users/m-mokhtari/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m-mokhtari/subscriptions","organizations_url":"https://api.github.com/users/m-mokhtari/orgs","repos_url":"https://api.github.com/users/m-mokhtari/repos","events_url":"https://api.github.com/users/m-mokhtari/events{/privacy}","received_events_url":"https://api.github.com/users/m-mokhtari/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/gator-life/gator/pulls/10/commits","review_comments_url":"https://api.github.com/repos/gator-life/gator/pulls/10/comments","review_comment_url":"https://api.github.com/repos/gator-life/gator/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gator-life/gator/issues/10/comments","statuses_url":"https://api.github.com/repos/gator-life/gator/statuses/c3812b868bacce31a2ce907cb4bce69356afbbf2","head":{"label":"gator-life:feature/Feature-encoding","ref":"feature/Feature-encoding","sha":"c3812b868bacce31a2ce907cb4bce69356afbbf2","user":{"login":"gator-life","id":12819536,"avatar_url":"https://avatars.githubusercontent.com/u/12819536?v=3","gravatar_id":"","url":"https://api.github.com/users/gator-life","html_url":"https://github.com/gator-life","followers_url":"https://api.github.com/users/gator-life/followers","following_url":"https://api.github.com/users/gator-life/following{/other_user}","gists_url":"https://api.github.com/users/gator-life/gists{/gist_id}","starred_url":"https://api.github.com/users/gator-life/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gator-life/subscriptions","organizations_url":"https://api.github.com/users/gator-life/orgs","repos_url":"https://api.github.com/users/gator-life/repos","events_url":"https://api.github.com/users/gator-life/events{/privacy}","received_events_url":"https://api.github.com/users/gator-life/received_events","type":"Organization","site_admin":false},"repo":{"id":37155850,"name":"gator","full_name":"gator-life/gator","owner":{"login":"gator-life","id":12819536,"avatar_url":"https://avatars.githubusercontent.com/u/12819536?v=3","gravatar_id":"","url":"https://api.github.com/users/gator-life","html_url":"https://github.com/gator-life","followers_url":"https://api.github.com/users/gator-life/followers","following_url":"https://api.github.com/users/gator-life/following{/other_user}","gists_url":"https://api.github.com/users/gator-life/gists{/gist_id}","starred_url":"https://api.github.com/users/gator-life/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gator-life/subscriptions","organizations_url":"https://api.github.com/users/gator-life/orgs","repos_url":"https://api.github.com/users/gator-life/repos","events_url":"https://api.github.com/users/gator-life/events{/privacy}","received_events_url":"https://api.github.com/users/gator-life/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gator-life/gator","description":"","fork":false,"url":"https://api.github.com/repos/gator-life/gator","forks_url":"https://api.github.com/repos/gator-life/gator/forks","keys_url":"https://api.github.com/repos/gator-life/gator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gator-life/gator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gator-life/gator/teams","hooks_url":"https://api.github.com/repos/gator-life/gator/hooks","issue_events_url":"https://api.github.com/repos/gator-life/gator/issues/events{/number}","events_url":"https://api.github.com/repos/gator-life/gator/events","assignees_url":"https://api.github.com/repos/gator-life/gator/assignees{/user}","branches_url":"https://api.github.com/repos/gator-life/gator/branches{/branch}","tags_url":"https://api.github.com/repos/gator-life/gator/tags","blobs_url":"https://api.github.com/repos/gator-life/gator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gator-life/gator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gator-life/gator/git/refs{/sha}","trees_url":"https://api.github.com/repos/gator-life/gator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gator-life/gator/statuses/{sha}","languages_url":"https://api.github.com/repos/gator-life/gator/languages","stargazers_url":"https://api.github.com/repos/gator-life/gator/stargazers","contributors_url":"https://api.github.com/repos/gator-life/gator/contributors","subscribers_url":"https://api.github.com/repos/gator-life/gator/subscribers","subscription_url":"https://api.github.com/repos/gator-life/gator/subscription","commits_url":"https://api.github.com/repos/gator-life/gator/commits{/sha}","git_commits_url":"https://api.github.com/repos/gator-life/gator/git/commits{/sha}","comments_url":"https://api.github.com/repos/gator-life/gator/comments{/number}","issue_comment_url":"https://api.github.com/repos/gator-life/gator/issues/comments{/number}","contents_url":"https://api.github.com/repos/gator-life/gator/contents/{+path}","compare_url":"https://api.github.com/repos/gator-life/gator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gator-life/gator/merges","archive_url":"https://api.github.com/repos/gator-life/gator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gator-life/gator/downloads","issues_url":"https://api.github.com/repos/gator-life/gator/issues{/number}","pulls_url":"https://api.github.com/repos/gator-life/gator/pulls{/number}","milestones_url":"https://api.github.com/repos/gator-life/gator/milestones{/number}","notifications_url":"https://api.github.com/repos/gator-life/gator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gator-life/gator/labels{/name}","releases_url":"https://api.github.com/repos/gator-life/gator/releases{/id}","created_at":"2015-06-09T20:14:35Z","updated_at":"2015-06-09T20:38:10Z","pushed_at":"2015-08-05T07:21:02Z","git_url":"git://github.com/gator-life/gator.git","ssh_url":"git@github.com:gator-life/gator.git","clone_url":"https://github.com/gator-life/gator.git","svn_url":"https://github.com/gator-life/gator","homepage":null,"size":1532,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":8,"forks":0,"open_issues":8,"watchers":0,"default_branch":"master"}},"base":{"label":"gator-life:master","ref":"master","sha":"3da1aade396942fb1671174cce9073f2f2bf0048","user":{"login":"gator-life","id":12819536,"avatar_url":"https://avatars.githubusercontent.com/u/12819536?v=3","gravatar_id":"","url":"https://api.github.com/users/gator-life","html_url":"https://github.com/gator-life","followers_url":"https://api.github.com/users/gator-life/followers","following_url":"https://api.github.com/users/gator-life/following{/other_user}","gists_url":"https://api.github.com/users/gator-life/gists{/gist_id}","starred_url":"https://api.github.com/users/gator-life/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gator-life/subscriptions","organizations_url":"https://api.github.com/users/gator-life/orgs","repos_url":"https://api.github.com/users/gator-life/repos","events_url":"https://api.github.com/users/gator-life/events{/privacy}","received_events_url":"https://api.github.com/users/gator-life/received_events","type":"Organization","site_admin":false},"repo":{"id":37155850,"name":"gator","full_name":"gator-life/gator","owner":{"login":"gator-life","id":12819536,"avatar_url":"https://avatars.githubusercontent.com/u/12819536?v=3","gravatar_id":"","url":"https://api.github.com/users/gator-life","html_url":"https://github.com/gator-life","followers_url":"https://api.github.com/users/gator-life/followers","following_url":"https://api.github.com/users/gator-life/following{/other_user}","gists_url":"https://api.github.com/users/gator-life/gists{/gist_id}","starred_url":"https://api.github.com/users/gator-life/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gator-life/subscriptions","organizations_url":"https://api.github.com/users/gator-life/orgs","repos_url":"https://api.github.com/users/gator-life/repos","events_url":"https://api.github.com/users/gator-life/events{/privacy}","received_events_url":"https://api.github.com/users/gator-life/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gator-life/gator","description":"","fork":false,"url":"https://api.github.com/repos/gator-life/gator","forks_url":"https://api.github.com/repos/gator-life/gator/forks","keys_url":"https://api.github.com/repos/gator-life/gator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gator-life/gator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gator-life/gator/teams","hooks_url":"https://api.github.com/repos/gator-life/gator/hooks","issue_events_url":"https://api.github.com/repos/gator-life/gator/issues/events{/number}","events_url":"https://api.github.com/repos/gator-life/gator/events","assignees_url":"https://api.github.com/repos/gator-life/gator/assignees{/user}","branches_url":"https://api.github.com/repos/gator-life/gator/branches{/branch}","tags_url":"https://api.github.com/repos/gator-life/gator/tags","blobs_url":"https://api.github.com/repos/gator-life/gator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gator-life/gator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gator-life/gator/git/refs{/sha}","trees_url":"https://api.github.com/repos/gator-life/gator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gator-life/gator/statuses/{sha}","languages_url":"https://api.github.com/repos/gator-life/gator/languages","stargazers_url":"https://api.github.com/repos/gator-life/gator/stargazers","contributors_url":"https://api.github.com/repos/gator-life/gator/contributors","subscribers_url":"https://api.github.com/repos/gator-life/gator/subscribers","subscription_url":"https://api.github.com/repos/gator-life/gator/subscription","commits_url":"https://api.github.com/repos/gator-life/gator/commits{/sha}","git_commits_url":"https://api.github.com/repos/gator-life/gator/git/commits{/sha}","comments_url":"https://api.github.com/repos/gator-life/gator/comments{/number}","issue_comment_url":"https://api.github.com/repos/gator-life/gator/issues/comments{/number}","contents_url":"https://api.github.com/repos/gator-life/gator/contents/{+path}","compare_url":"https://api.github.com/repos/gator-life/gator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gator-life/gator/merges","archive_url":"https://api.github.com/repos/gator-life/gator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gator-life/gator/downloads","issues_url":"https://api.github.com/repos/gator-life/gator/issues{/number}","pulls_url":"https://api.github.com/repos/gator-life/gator/pulls{/number}","milestones_url":"https://api.github.com/repos/gator-life/gator/milestones{/number}","notifications_url":"https://api.github.com/repos/gator-life/gator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gator-life/gator/labels{/name}","releases_url":"https://api.github.com/repos/gator-life/gator/releases{/id}","created_at":"2015-06-09T20:14:35Z","updated_at":"2015-06-09T20:38:10Z","pushed_at":"2015-08-05T07:21:02Z","git_url":"git://github.com/gator-life/gator.git","ssh_url":"git@github.com:gator-life/gator.git","clone_url":"https://github.com/gator-life/gator.git","svn_url":"https://github.com/gator-life/gator","homepage":null,"size":1532,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":8,"forks":0,"open_issues":8,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gator-life/gator/pulls/10"},"html":{"href":"https://github.com/gator-life/gator/pull/10"},"issue":{"href":"https://api.github.com/repos/gator-life/gator/issues/10"},"comments":{"href":"https://api.github.com/repos/gator-life/gator/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/gator-life/gator/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/gator-life/gator/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gator-life/gator/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/gator-life/gator/statuses/c3812b868bacce31a2ce907cb4bce69356afbbf2"}}}}