问题
Firstly, I'd like to say that I do not want to use any libraries that are not provided with Python 2.7.10. The same question was posted on Stack Overflow but was answered with the Requests library.
I have a script that logs into Roblox.com using urllib2. To check if there is a captcha before I try to log in, I wanted to do check_captcha = re.findall('recaptcha_image', newlogin)
but roblox needs to redirect to the captcha login page AND the captcha has to load onto the page.
So how can I make Python wait to redirect/load the page fully before I go ahead and .read()
and scrape it.
回答1:
This will wait 10 seconds before it reads it:
import urllib2
import time
url = 'Roblox url'
data = urllib2.urlopen(url)
time.sleep(10)
data = data.read()
来源:https://stackoverflow.com/questions/31310321/python-urllib2-wait-for-page-to-load-to-scrape-data