|
|
|
@ -38,12 +38,6 @@ def getsource(url):
|
|
|
|
|
return response
|
|
|
|
|
|
|
|
|
|
def useRequests(url):
|
|
|
|
|
|
|
|
|
|
def write2html(res):
|
|
|
|
|
filename = 'historyPrice.html'
|
|
|
|
|
with open(filename, mode = 'w+', encoding='utf-8') as fd:
|
|
|
|
|
fd.write(res)
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
session = requests.Session()
|
|
|
|
|
res = session.get(url, headers = headers)
|
|
|
|
@ -52,7 +46,6 @@ def useRequests(url):
|
|
|
|
|
res.encoding = res.apparent_encoding
|
|
|
|
|
res = etree.HTML(res.text)
|
|
|
|
|
source = etree.tostring(res, encoding = 'utf-8', pretty_print = True, method = 'html').decode('utf-8')
|
|
|
|
|
# write2html(res)
|
|
|
|
|
return source
|
|
|
|
|
except BaseException as e:
|
|
|
|
|
print(e)
|
|
|
|
@ -61,7 +54,7 @@ def useRequests(url):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
jdurl = r"https://item.jd.com/10036840192083.html"
|
|
|
|
|
jdurl = r"https://item.jd.com/10023043997421.html"
|
|
|
|
|
url = r"https://www.vveby.com/search?keyword=" + jdurl
|
|
|
|
|
print(url)
|
|
|
|
|
useRequests(url)
|
|
|
|
|