0
以此爲出發點.. http://docs.python-guide.org/en/latest/scenarios/scrape/的Python刮網站,請求和LXML ..
from lxml import html
import requests
page = requests.get('http://econpy.pythonanywhere.com/ex/001.html')
tree = html.fromstring(page.text)
一切正常expected..But,....
from lxml import html
import requests
page = requests.get('http://www.streetinsider.com/ipo_history.php?type=upcoming')
tree = html.fromstring(page.text)
給出了這樣的錯誤...
File "<string>", line unknown
XMLSyntaxError: line 1: Document is empty
使用pyquery ....
from pyquery import PyQuery as pq
from lxml import etree,html
import requests
response = pq(url='http://www.streetinsider.com/ipo_history.php?type=upcoming')
doc = pq(response.content)
拋出這個錯誤...
File "<string>", line unknown
XMLSyntaxError: line 1504: Unexpected end tag : h2
任何從網頁獲取表的幫助。
你能得到表...還是顯示'頁面'不是空白.... – Merlin
上面的代碼從服務器接收到非空的HTTP主體。 – rein