Python Mechanize : Page not loading fully
The code snippet i am using ::
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]
response = br.open('http://www.facebook.com')
br.select_form(nr=0)
br['email'] = USE开发者_运维知识库RNAME
br['pass'] = PASSWORD
response2 = br.submit()
assert br.viewing_html()
time.sleep(50)
for form in br.forms():
print form
Well i tried writing out response2.read() to file to see what was happening . Only the top navigation bar has loaded . The intention of having time.sleep(50) was to provide time for page load but guess that doesnt work .
What is the right way to do this ?
Are you sure you're passing the correct login?
I've run your code with my login and it works fine for me.
The only thing I'll add is that you don't need the time.sleep(50)
in there—Mechanize blocks until it receives all the content.
Make your question more useful by giving us your complete code sample and the output (including print response2
).
You shouldn't be scraping www.facebook.com.
The right way to get what you are after is to use Facebook Platform as @infrared notes.
精彩评论