私はhttp://www.neimanmarcus.com/Stuart-Weitzman-Reserve-Suede-Over-the-Knee-Boot-Black/prod179890262/p.prodページの読み込みが完了するまでの待ち時間は?
から入手できるブートサイズ(下の$(「option.addedOptionを」))を取得しようとしている私は、コードの下にしようとしたが、サイズが持っている前に、それが常に返さ。
# config.url = 'http://www.neimanmarcus.com/Stuart-Weitzman-Reserve-Suede-Over-the-Knee-Boot-Black/prod179890262/p.prod'
import urllib2
import requests
import config
import time
from lxml.cssselect import CSSSelector
from lxml.html import fromstring
print config.url
headers = {
"Host": "www.neimanmarcus.com",
"Connection": "keep-alive",
"Content-Length": 106,
"Pragma": "no-cache",
"Cache-Control": "no-cache",
"Accept": "*/*",
"Origin": "http://www.neimanmarcus.com",
"X-Requested-With": "XMLHttpRequest",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"Referer": "http://www.neimanmarcus.com/Stuart-Weitzman-Reserve-Suede-Over-the-Knee-Boot-Black/prod179890262/p.prod",
"Accept-Language": "en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4,fr;q=0.2,cs;q=0.2,zh-TW;q=0.2"
}
request = urllib2.Request(config.url, headers=headers)
html = urllib2.urlopen(request)
time.sleep(10)
html = html.read()
print html
html = fromstring(html)
sel = CSSSelector('option.addedOption')
try:
options = sel(html)
print options
except Exception as e:
print e
Iは、サイズが(実際にヘッダがこのリクエストのリクエストヘッダに基づいて作成された)要求「http://www.neimanmarcus.com/product.service」になっているが見つかりました。
ページ情報全体(特にブートサイズ)を取得するにはどうすればよいですか?
また、私はhttp://www.neimanmarcus.com/product.serviceを直接要求してみましたが失敗しました。
ありがとうございます。私は後でそれを試してみる。 – Cuero