All, My python program signs onto the student facebook at my school and, given email addresses, returns the associated full name. If I were to do this through a regular browser, there is also a picture of the individual, and I am trying to get my program to download the picture as well. The problem: the html code of the page does not point to a particular file, but rather refers to (what seems like) a query.
So, if one went to the facebook and searched for me using my school net id (msb83), the image of my profile on the results page is: <img width="100" height="130" border="0" class="border" alt="msb83" src="deliverImage.cfm?netid=MSB83"> Using BeautifulSoup, mechanize, and urllib, I've constructed the following: br.open("http://www.school.edu/students/facebook/") br.select_form(nr = 1) br.form['fulltextsearch'] = 'msb83' # this searches the facebook for me br.submit() results = br.response().read() soup = BeautifulSoup(results) foo2 = soup.find('td', attrs={'width':'95'}) foo3 = foo2.find('a') foo4 = foo3.find('img', attrs={'src':'deliverImage.cfm?netid=msb83'}) # this just drills down to the <img> line and until this point the program does not return an error save_as = os.path.join('./', msb83 + '.jpg') urllib.urlretrieve(foo4, save_as) I get the following error msg after running this code: AttributeError: 'NoneType' object has no attribute 'strip' I can download the picture through my browser by right-clicking, selecting save as, and then the image gets saved as 'deliverImage.cfm.jpeg.' Are there any suggestions as to how I might be able to download the image using python? Please let me know if more information is needed -- happy to supply it. Matt -- http://mail.python.org/mailman/listinfo/python-list