Dec-21-2016, 07:09 PM
Hello one and all,
I am back with , I hope is a small problem. I found this image scraper that looks just what I been looking for. I been working on this one error for over a week now. I google it and I can't find anything that is close to what I have here.
Here is the code, I am using python 2.7.12 on wim 7:
The error is this:
Traceback (most recent call last):
File "C:/Users/renny and kite/Desktop/play_with_image/test_1.py", line 25, in <module>
br = mechanize.browser()
AttributeError: 'module' object has no attribute 'browser'
I just don't know what attribute I should put in this function br = mechanize.browser()
I been to a few sites, but can't find anything about mechanize.browser()
site one http://wwwsearch.sourceforge.net/mechanize/doc.html
site two http://stockrt.github.io/p/emulating-a-b...mechanize/
site three http://www.pythonforbeginners.com/mechan...mechanize/, now I found this code[br = mechanize.browser()] on this site, but I could not get it to work.
So no luck so far, that is why I am here again. Hope someone can help, I would like to get this peace of code to work.
Thank you
I am back with , I hope is a small problem. I found this image scraper that looks just what I been looking for. I been working on this one error for over a week now. I google it and I can't find anything that is close to what I have here.
Here is the code, I am using python 2.7.12 on wim 7:
import requests import mechanize from lxml import html import sys import urlparse import time def grab_my_pictures(): respones = requests.get(final_link) parsed_body = html.fromstring(response.text) images = parsed_body.xpath('//img/@src') if not images: sys.exit("Found no images") images = [urlparse.urljoin(response.url, url)for url in images] print 'Found %s images' % len(images) for url in images[1:50]: r = requests.get(url) r = open('pics2/%s' % url.split('/')[-1], 'w') f.write(r.content) f.close() website_name = raw_input("Please enter the name of the website ") list_of_links = [] br = mechanize.browser() br.set_handle_robot(False) final_website = "http//" + website_name print final_website respons = br.open("http//" + website_name)Their still some code that I do not know what it does, I been taking it line by line learning what each line does.
The error is this:
Traceback (most recent call last):
File "C:/Users/renny and kite/Desktop/play_with_image/test_1.py", line 25, in <module>
br = mechanize.browser()
AttributeError: 'module' object has no attribute 'browser'
I just don't know what attribute I should put in this function br = mechanize.browser()
I been to a few sites, but can't find anything about mechanize.browser()
site one http://wwwsearch.sourceforge.net/mechanize/doc.html
site two http://stockrt.github.io/p/emulating-a-b...mechanize/
site three http://www.pythonforbeginners.com/mechan...mechanize/, now I found this code[br = mechanize.browser()] on this site, but I could not get it to work.
So no luck so far, that is why I am here again. Hope someone can help, I would like to get this peace of code to work.
Thank you