{"action":"created","comment":{"url":"https://api.github.com/repos/cshinaver/BookFinder/pulls/comments/41302163","id":41302163,"diff_hunk":"@@ -171,3 +171,161 @@ def get_book_type(item):\n     book_lists = map(parse_book_list_item_into_books, items)\n     return [item for sublist in book_lists for item in sublist]\n \n+\n+\n+\n+def get_google_books_search_page_for_isbn(isbn):\n+    search_string = (\n+        'https://books.google.com/books?isbn='\n+        '{search_string}'.format(search_string=isbn,)\n+    )\n+    return requests.get(search_string).content\n+\n+\n+def extract_google_books_page_link_from_li(item):\n+    h3_item = item.find(\n+        'h3',\n+        class_='r',\n+    )\n+    a_item = h3_item.find('a')\n+    return a_item.attrs['href']\n+\n+\n+def get_google_books_page_link_for_isbn(isbn):\n+    content = get_google_books_search_page_for_isbn(isbn)\n+    soup = BeautifulSoup(content)\n+    item = soup.find('li', class_='g')\n+    link = extract_google_books_page_link_from_li(item)\n+    return link\n+\n+\n+# Sometimes link is a redirect link in google's format.\n+# This function translates that to a direct link.\n+def convert_google_redirect_to_direct_link(redir_link):\n+    link_pos = redir_link.find('&q=') + 3\n+    if not redir_link.startswith('/url?'):\n+        return redir_link\n+    # returns -1 if not found\n+    if link_pos==2:\n+        return redir_link\n+    link_sub = redir_link[link_pos:]\n+    full_redir_link = 'https://www.google.com/url?rct=j&url=' + link_sub\n+    content = requests.get(full_redir_link).content\n+    soup = BeautifulSoup(content)\n+    body = soup.find('body')\n+    # if has no body, is probably actually a redirect page - grab the redirect link\n+    # otherwise, is probably a redirect warning - pull the continue link\n+    if body==None:\n+        META = soup.find('meta')\n+        meta_content = META.attrs['content']\n+        link = meta_content[7:]\n+        link = link[:(len(link) - 1)]\n+    else:\n+        all_links = soup.find_all('a')\n+        first_link = all_links[0]\n+        link = first_link.attrs['href']\n+    return link\n+\n+\n+def extract_google_books_price_list_from_link(link):\n+    #print link","path":"scraper.py","position":61,"original_position":61,"commit_id":"94631b6007f04b13ede2cbae45c5b11ff9aad64c","original_commit_id":"94631b6007f04b13ede2cbae45c5b11ff9aad64c","user":{"login":"cshinaver","id":7769334,"avatar_url":"https://avatars.githubusercontent.com/u/7769334?v=3","gravatar_id":"","url":"https://api.github.com/users/cshinaver","html_url":"https://github.com/cshinaver","followers_url":"https://api.github.com/users/cshinaver/followers","following_url":"https://api.github.com/users/cshinaver/following{/other_user}","gists_url":"https://api.github.com/users/cshinaver/gists{/gist_id}","starred_url":"https://api.github.com/users/cshinaver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cshinaver/subscriptions","organizations_url":"https://api.github.com/users/cshinaver/orgs","repos_url":"https://api.github.com/users/cshinaver/repos","events_url":"https://api.github.com/users/cshinaver/events{/privacy}","received_events_url":"https://api.github.com/users/cshinaver/received_events","type":"User","site_admin":false},"body":"Commented out code is useless code. Better to remove. ","created_at":"2015-10-06T18:22:54Z","updated_at":"2015-10-06T18:22:54Z","html_url":"https://github.com/cshinaver/BookFinder/pull/24#discussion_r41302163","pull_request_url":"https://api.github.com/repos/cshinaver/BookFinder/pulls/24","_links":{"self":{"href":"https://api.github.com/repos/cshinaver/BookFinder/pulls/comments/41302163"},"html":{"href":"https://github.com/cshinaver/BookFinder/pull/24#discussion_r41302163"},"pull_request":{"href":"https://api.github.com/repos/cshinaver/BookFinder/pulls/24"}}},"pull_request":{"url":"https://api.github.com/repos/cshinaver/BookFinder/pulls/24","id":46872639,"html_url":"https://github.com/cshinaver/BookFinder/pull/24","diff_url":"https://github.com/cshinaver/BookFinder/pull/24.diff","patch_url":"https://github.com/cshinaver/BookFinder/pull/24.patch","issue_url":"https://api.github.com/repos/cshinaver/BookFinder/issues/24","number":24,"state":"open","locked":false,"title":"Add google books data scraper","user":{"login":"jhuseman","id":11066239,"avatar_url":"https://avatars.githubusercontent.com/u/11066239?v=3","gravatar_id":"","url":"https://api.github.com/users/jhuseman","html_url":"https://github.com/jhuseman","followers_url":"https://api.github.com/users/jhuseman/followers","following_url":"https://api.github.com/users/jhuseman/following{/other_user}","gists_url":"https://api.github.com/users/jhuseman/gists{/gist_id}","starred_url":"https://api.github.com/users/jhuseman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhuseman/subscriptions","organizations_url":"https://api.github.com/users/jhuseman/orgs","repos_url":"https://api.github.com/users/jhuseman/repos","events_url":"https://api.github.com/users/jhuseman/events{/privacy}","received_events_url":"https://api.github.com/users/jhuseman/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-06T08:05:27Z","updated_at":"2015-10-06T18:22:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dd030b8484f1687d53faa0307bfce0e9155766e6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cshinaver/BookFinder/pulls/24/commits","review_comments_url":"https://api.github.com/repos/cshinaver/BookFinder/pulls/24/comments","review_comment_url":"https://api.github.com/repos/cshinaver/BookFinder/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cshinaver/BookFinder/issues/24/comments","statuses_url":"https://api.github.com/repos/cshinaver/BookFinder/statuses/94631b6007f04b13ede2cbae45c5b11ff9aad64c","head":{"label":"cshinaver:issue_7","ref":"issue_7","sha":"94631b6007f04b13ede2cbae45c5b11ff9aad64c","user":{"login":"cshinaver","id":7769334,"avatar_url":"https://avatars.githubusercontent.com/u/7769334?v=3","gravatar_id":"","url":"https://api.github.com/users/cshinaver","html_url":"https://github.com/cshinaver","followers_url":"https://api.github.com/users/cshinaver/followers","following_url":"https://api.github.com/users/cshinaver/following{/other_user}","gists_url":"https://api.github.com/users/cshinaver/gists{/gist_id}","starred_url":"https://api.github.com/users/cshinaver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cshinaver/subscriptions","organizations_url":"https://api.github.com/users/cshinaver/orgs","repos_url":"https://api.github.com/users/cshinaver/repos","events_url":"https://api.github.com/users/cshinaver/events{/privacy}","received_events_url":"https://api.github.com/users/cshinaver/received_events","type":"User","site_admin":false},"repo":{"id":42416214,"name":"BookFinder","full_name":"cshinaver/BookFinder","owner":{"login":"cshinaver","id":7769334,"avatar_url":"https://avatars.githubusercontent.com/u/7769334?v=3","gravatar_id":"","url":"https://api.github.com/users/cshinaver","html_url":"https://github.com/cshinaver","followers_url":"https://api.github.com/users/cshinaver/followers","following_url":"https://api.github.com/users/cshinaver/following{/other_user}","gists_url":"https://api.github.com/users/cshinaver/gists{/gist_id}","starred_url":"https://api.github.com/users/cshinaver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cshinaver/subscriptions","organizations_url":"https://api.github.com/users/cshinaver/orgs","repos_url":"https://api.github.com/users/cshinaver/repos","events_url":"https://api.github.com/users/cshinaver/events{/privacy}","received_events_url":"https://api.github.com/users/cshinaver/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cshinaver/BookFinder","description":"BookFinder","fork":false,"url":"https://api.github.com/repos/cshinaver/BookFinder","forks_url":"https://api.github.com/repos/cshinaver/BookFinder/forks","keys_url":"https://api.github.com/repos/cshinaver/BookFinder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cshinaver/BookFinder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cshinaver/BookFinder/teams","hooks_url":"https://api.github.com/repos/cshinaver/BookFinder/hooks","issue_events_url":"https://api.github.com/repos/cshinaver/BookFinder/issues/events{/number}","events_url":"https://api.github.com/repos/cshinaver/BookFinder/events","assignees_url":"https://api.github.com/repos/cshinaver/BookFinder/assignees{/user}","branches_url":"https://api.github.com/repos/cshinaver/BookFinder/branches{/branch}","tags_url":"https://api.github.com/repos/cshinaver/BookFinder/tags","blobs_url":"https://api.github.com/repos/cshinaver/BookFinder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cshinaver/BookFinder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cshinaver/BookFinder/git/refs{/sha}","trees_url":"https://api.github.com/repos/cshinaver/BookFinder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cshinaver/BookFinder/statuses/{sha}","languages_url":"https://api.github.com/repos/cshinaver/BookFinder/languages","stargazers_url":"https://api.github.com/repos/cshinaver/BookFinder/stargazers","contributors_url":"https://api.github.com/repos/cshinaver/BookFinder/contributors","subscribers_url":"https://api.github.com/repos/cshinaver/BookFinder/subscribers","subscription_url":"https://api.github.com/repos/cshinaver/BookFinder/subscription","commits_url":"https://api.github.com/repos/cshinaver/BookFinder/commits{/sha}","git_commits_url":"https://api.github.com/repos/cshinaver/BookFinder/git/commits{/sha}","comments_url":"https://api.github.com/repos/cshinaver/BookFinder/comments{/number}","issue_comment_url":"https://api.github.com/repos/cshinaver/BookFinder/issues/comments{/number}","contents_url":"https://api.github.com/repos/cshinaver/BookFinder/contents/{+path}","compare_url":"https://api.github.com/repos/cshinaver/BookFinder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cshinaver/BookFinder/merges","archive_url":"https://api.github.com/repos/cshinaver/BookFinder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cshinaver/BookFinder/downloads","issues_url":"https://api.github.com/repos/cshinaver/BookFinder/issues{/number}","pulls_url":"https://api.github.com/repos/cshinaver/BookFinder/pulls{/number}","milestones_url":"https://api.github.com/repos/cshinaver/BookFinder/milestones{/number}","notifications_url":"https://api.github.com/repos/cshinaver/BookFinder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cshinaver/BookFinder/labels{/name}","releases_url":"https://api.github.com/repos/cshinaver/BookFinder/releases{/id}","created_at":"2015-09-13T23:02:30Z","updated_at":"2015-10-02T04:13:18Z","pushed_at":"2015-10-06T08:05:28Z","git_url":"git://github.com/cshinaver/BookFinder.git","ssh_url":"git@github.com:cshinaver/BookFinder.git","clone_url":"https://github.com/cshinaver/BookFinder.git","svn_url":"https://github.com/cshinaver/BookFinder","homepage":"","size":360,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":6,"forks":0,"open_issues":6,"watchers":0,"default_branch":"master"}},"base":{"label":"cshinaver:master","ref":"master","sha":"7159d158457a76cbb05832f3117fb6f88a869b70","user":{"login":"cshinaver","id":7769334,"avatar_url":"https://avatars.githubusercontent.com/u/7769334?v=3","gravatar_id":"","url":"https://api.github.com/users/cshinaver","html_url":"https://github.com/cshinaver","followers_url":"https://api.github.com/users/cshinaver/followers","following_url":"https://api.github.com/users/cshinaver/following{/other_user}","gists_url":"https://api.github.com/users/cshinaver/gists{/gist_id}","starred_url":"https://api.github.com/users/cshinaver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cshinaver/subscriptions","organizations_url":"https://api.github.com/users/cshinaver/orgs","repos_url":"https://api.github.com/users/cshinaver/repos","events_url":"https://api.github.com/users/cshinaver/events{/privacy}","received_events_url":"https://api.github.com/users/cshinaver/received_events","type":"User","site_admin":false},"repo":{"id":42416214,"name":"BookFinder","full_name":"cshinaver/BookFinder","owner":{"login":"cshinaver","id":7769334,"avatar_url":"https://avatars.githubusercontent.com/u/7769334?v=3","gravatar_id":"","url":"https://api.github.com/users/cshinaver","html_url":"https://github.com/cshinaver","followers_url":"https://api.github.com/users/cshinaver/followers","following_url":"https://api.github.com/users/cshinaver/following{/other_user}","gists_url":"https://api.github.com/users/cshinaver/gists{/gist_id}","starred_url":"https://api.github.com/users/cshinaver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cshinaver/subscriptions","organizations_url":"https://api.github.com/users/cshinaver/orgs","repos_url":"https://api.github.com/users/cshinaver/repos","events_url":"https://api.github.com/users/cshinaver/events{/privacy}","received_events_url":"https://api.github.com/users/cshinaver/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cshinaver/BookFinder","description":"BookFinder","fork":false,"url":"https://api.github.com/repos/cshinaver/BookFinder","forks_url":"https://api.github.com/repos/cshinaver/BookFinder/forks","keys_url":"https://api.github.com/repos/cshinaver/BookFinder/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cshinaver/BookFinder/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cshinaver/BookFinder/teams","hooks_url":"https://api.github.com/repos/cshinaver/BookFinder/hooks","issue_events_url":"https://api.github.com/repos/cshinaver/BookFinder/issues/events{/number}","events_url":"https://api.github.com/repos/cshinaver/BookFinder/events","assignees_url":"https://api.github.com/repos/cshinaver/BookFinder/assignees{/user}","branches_url":"https://api.github.com/repos/cshinaver/BookFinder/branches{/branch}","tags_url":"https://api.github.com/repos/cshinaver/BookFinder/tags","blobs_url":"https://api.github.com/repos/cshinaver/BookFinder/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cshinaver/BookFinder/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cshinaver/BookFinder/git/refs{/sha}","trees_url":"https://api.github.com/repos/cshinaver/BookFinder/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cshinaver/BookFinder/statuses/{sha}","languages_url":"https://api.github.com/repos/cshinaver/BookFinder/languages","stargazers_url":"https://api.github.com/repos/cshinaver/BookFinder/stargazers","contributors_url":"https://api.github.com/repos/cshinaver/BookFinder/contributors","subscribers_url":"https://api.github.com/repos/cshinaver/BookFinder/subscribers","subscription_url":"https://api.github.com/repos/cshinaver/BookFinder/subscription","commits_url":"https://api.github.com/repos/cshinaver/BookFinder/commits{/sha}","git_commits_url":"https://api.github.com/repos/cshinaver/BookFinder/git/commits{/sha}","comments_url":"https://api.github.com/repos/cshinaver/BookFinder/comments{/number}","issue_comment_url":"https://api.github.com/repos/cshinaver/BookFinder/issues/comments{/number}","contents_url":"https://api.github.com/repos/cshinaver/BookFinder/contents/{+path}","compare_url":"https://api.github.com/repos/cshinaver/BookFinder/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cshinaver/BookFinder/merges","archive_url":"https://api.github.com/repos/cshinaver/BookFinder/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cshinaver/BookFinder/downloads","issues_url":"https://api.github.com/repos/cshinaver/BookFinder/issues{/number}","pulls_url":"https://api.github.com/repos/cshinaver/BookFinder/pulls{/number}","milestones_url":"https://api.github.com/repos/cshinaver/BookFinder/milestones{/number}","notifications_url":"https://api.github.com/repos/cshinaver/BookFinder/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cshinaver/BookFinder/labels{/name}","releases_url":"https://api.github.com/repos/cshinaver/BookFinder/releases{/id}","created_at":"2015-09-13T23:02:30Z","updated_at":"2015-10-02T04:13:18Z","pushed_at":"2015-10-06T08:05:28Z","git_url":"git://github.com/cshinaver/BookFinder.git","ssh_url":"git@github.com:cshinaver/BookFinder.git","clone_url":"https://github.com/cshinaver/BookFinder.git","svn_url":"https://github.com/cshinaver/BookFinder","homepage":"","size":360,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":6,"forks":0,"open_issues":6,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cshinaver/BookFinder/pulls/24"},"html":{"href":"https://github.com/cshinaver/BookFinder/pull/24"},"issue":{"href":"https://api.github.com/repos/cshinaver/BookFinder/issues/24"},"comments":{"href":"https://api.github.com/repos/cshinaver/BookFinder/issues/24/comments"},"review_comments":{"href":"https://api.github.com/repos/cshinaver/BookFinder/pulls/24/comments"},"review_comment":{"href":"https://api.github.com/repos/cshinaver/BookFinder/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cshinaver/BookFinder/pulls/24/commits"},"statuses":{"href":"https://api.github.com/repos/cshinaver/BookFinder/statuses/94631b6007f04b13ede2cbae45c5b11ff9aad64c"}}}}