Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing urlopen I can get the html of the page, but a crucial part is missing
    primarykey
    data
    text
    <p>I am trying to make a script that gets similar images from google using a url, using a part from <a href="http://breakingcode.wordpress.com/2010/06/29/google-search-python/" rel="nofollow">this</a> code.</p> <p>The problem is, that I want to get to <a href="https://www.google.com/search?hl=en&amp;q=http%3A%2F%2Fi.imgur.com%2FqGRxTNA.jpg&amp;btnG=Google+Search" rel="nofollow">this</a> link, because from it I can get to the images themselves by cloicking on the "search by image" link, but when I use the script, I get the exact same page, but without the "search by image" link.</p> <p>I would like to know why and if there is a way to fix it.</p> <p>Thanks a lot in advance!</p> <p>P.S. Here's the code</p> <pre><code>import os from urllib2 import Request, urlopen from cookielib import LWPCookieJar USER_AGENT = r"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)" LOCAL_PATH = r"C:\scripts\google_search" COOKIE_JAR_FILE = r".google-cookie" class google_search(object): def cleanup(self): if os.path.isfile(self.cookie_jar_path): os.remove(self.cookie_jar_path) os.chdir(LOCAL_PATH) for html in os.listdir("."): if html.endswith(".html"): os.remove(html) def __init__(self, cookie_jar_path): self.cookie_jar_path = cookie_jar_path self.cookie_jar = LWPCookieJar(self.cookie_jar_path) self.counter = 0 self.cleanup() try: cookie.load() except Exception: pass def get_html(self, url): request = Request(url = url) request.add_header("User-Agent", USER_AGENT) self.cookie_jar.add_cookie_header(request) response = urlopen(request) self.cookie_jar.extract_cookies(response, request) html_response = response.read() response.close() self.cookie_jar.save() return html_response def main(): url_2 = r"http://www.google.com/search?hl=en&amp;q=http%3A%2F%2Fi.imgur.com%2FqGRxTNA.jpg&amp;btnG=Google+Search" search = google_search(os.path.join(LOCAL_PATH, COOKIE_JAR_FILE)) html_2 = search.get_html(url_2) if __name__ == '__main__': main() </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload