|
|
@ -1,12 +1,12 @@
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
from selenium import webdriver
|
|
|
|
from selenium import webdriver
|
|
|
|
from selenium.webdriver.chrome.options import Options
|
|
|
|
from selenium.webdriver.chrome.options import Options
|
|
|
|
from lxml import etree
|
|
|
|
from lxml import etree
|
|
|
|
import random
|
|
|
|
import random
|
|
|
|
import settings
|
|
|
|
import settings
|
|
|
|
import time
|
|
|
|
import requests
|
|
|
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
|
|
headers = {
|
|
|
|
headers = {
|
|
|
|
'User-Agent': random.choice(settings.USER_AGENT)
|
|
|
|
'User-Agent': random.choice(settings.USER_AGENT)
|
|
|
@ -34,61 +34,14 @@ def getsource(url):
|
|
|
|
driver.close()
|
|
|
|
driver.close()
|
|
|
|
return response
|
|
|
|
return response
|
|
|
|
|
|
|
|
|
|
|
|
def manmanbuy(url):
|
|
|
|
def useRequests(url):
|
|
|
|
initChrome = Options()
|
|
|
|
pass
|
|
|
|
'''
|
|
|
|
|
|
|
|
initChrome.add_argument('--no-sandbox')
|
|
|
|
|
|
|
|
initChrome.add_argument('--headless')
|
|
|
|
|
|
|
|
initChrome.add_argument('--disable-gpu')
|
|
|
|
|
|
|
|
initChrome.add_argument("disable-cache")
|
|
|
|
|
|
|
|
initChrome.add_argument('disable-infobars')
|
|
|
|
|
|
|
|
initChrome.add_argument('log-level=3') # INFO = 0 WARNING = 1 LOG_ERROR = 2 LOG_FATAL = 3 default is 0
|
|
|
|
|
|
|
|
initChrome.add_experimental_option("excludeSwitches",['enable-automation','enable-logging'])
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# driver = webdriver.Chrome(chrome_options = initChrome, executable_path = './chromedriver.exe')
|
|
|
|
|
|
|
|
driver = webdriver.Chrome(executable_path = './chromedriver.exe')
|
|
|
|
|
|
|
|
# driver.get(url)
|
|
|
|
|
|
|
|
# time.sleep(10)
|
|
|
|
|
|
|
|
with open('cookies.json', 'r', encoding='utf-8') as fd:
|
|
|
|
|
|
|
|
listCookies = json.loads(fd.read())
|
|
|
|
|
|
|
|
for cookie in listCookies:
|
|
|
|
|
|
|
|
cookies = {
|
|
|
|
|
|
|
|
'domain': cookie['domain'],
|
|
|
|
|
|
|
|
'httpOnly': cookie['httpOnly'],
|
|
|
|
|
|
|
|
'name':cookie['name'],
|
|
|
|
|
|
|
|
'path':'/',
|
|
|
|
|
|
|
|
'secure': cookie['secure'],
|
|
|
|
|
|
|
|
'value':cookie['value'],
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
print(cookies)
|
|
|
|
|
|
|
|
driver.add_cookie(cookies)
|
|
|
|
|
|
|
|
driver.get(url)
|
|
|
|
|
|
|
|
time.sleep(10)
|
|
|
|
|
|
|
|
exit()
|
|
|
|
|
|
|
|
driver.implicitly_wait(10)
|
|
|
|
|
|
|
|
driver.get(url)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
response = etree.HTML(driver.page_source)
|
|
|
|
|
|
|
|
response = etree.tostring(response, encoding = "utf-8", pretty_print = True, method = "html")
|
|
|
|
|
|
|
|
response = response.decode('utf-8')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
driver.close()
|
|
|
|
|
|
|
|
return response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def saveCookies(driver):
|
|
|
|
|
|
|
|
jsonCookies = json.dumps(driver.get_cookies())
|
|
|
|
|
|
|
|
with open('cookies.json', 'w', encoding='utf-8') as fd:
|
|
|
|
|
|
|
|
fd.write(jsonCookies)
|
|
|
|
|
|
|
|
fd.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def buy():
|
|
|
|
|
|
|
|
jdurl = "https://item.jd.com/10047511027349.html"
|
|
|
|
|
|
|
|
url = "https://tool.manmanbuy.com/HistoryLowest.aspx?url=" + jdurl
|
|
|
|
|
|
|
|
# print(url)
|
|
|
|
|
|
|
|
response = manmanbuy(url)
|
|
|
|
|
|
|
|
print(response)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
if __name__ == "__main__":
|
|
|
|
buy()
|
|
|
|
jdurl = "https://item.jd.com/10036840192083.html"
|
|
|
|
|
|
|
|
url = "https://www.vveby.com/search?keyword=" + jdurl
|
|
|
|
|
|
|
|
with open('historyPrice.html', 'w+', encoding = 'utf-8') as fd:
|
|
|
|
|
|
|
|
fd.write(getsource(url))
|
|
|
|
|
|
|
|
fd.close()
|
|
|
|
|
|
|
|
print('done')
|