这样写有什么问题吗?
import requests
url = "http://www.doutula.com/"
headers ={
"User-Agent":"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.26 Safari/537.36 Core/1.63.6756.400 QQBrowser/10.3.2473.400,"
}
resp = requests.get(url,headers=headers)
print(resp.text)
from lxml import etree
html =etree.HTML(resp.text)
srcs = html.xpath(".//img/@data-original")
for src in srcs:
print(src)
print(len(srcs))
import requests
url = "http://www.doutula.com/"
headers ={
"User-Agent":"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.26 Safari/537.36 Core/1.63.6756.400 QQBrowser/10.3.2473.400,"
}
resp = requests.get(url,headers=headers)
print(resp.text)
from lxml import etree
html =etree.HTML(resp.text)
srcs = html.xpath(".//img/@data-original")
for src in srcs:
print(src)
print(len(srcs))