现在我想在交易板上搜索游戏物品。 所以我在源代码下做了一个爬虫
with(python 3.6 / Selenium / bs4 / Chromedrver)
这是我的来源
from selenium import webdriver
from bs4 import BeautifulSoup
import urllib
import time
import datetime
import sys
from retrying import retry
now = time.time()
until = 1518699000
print(datetime.datetime.fromtimestamp(now))
print(datetime.datetime.fromtimestamp(until))
driver = webdriver.Chrome('C:/chromeDR/chromedriver.exe')
driver.get('http://ro.gnjoy.com/itemDeal/dealSearch.asp')
driver.implicitly_wait(10)
html = driver.page_source
soup = BeautifulSoup(html, 'html.parser')
count = 1
while True:
dics = {'+7 엑소시스트 웨폰 쉐도우':40000000,'+7 액서큐서너 웨폰 쉐도우':25000000}
for keynum in dics.keys():
print (count)
print (keynum)
driver.find_element_by_name('itemFullName').send_keys(keynum)
driver.find_element_by_name('svrID').send_keys('바포메트')
log_but2 = '''//*[@id="itemContents"]/form/fieldset/button'''
**driver.find_element_by_xpath(log_but2).click()**
driver.implicitly_wait(10)
result = driver.page_source
resulthtml = BeautifulSoup(result, 'html.parser')
lists = resulthtml.find_all('span', {'class' : 'priceLv7'})
for i in lists:
price = int(i.text.replace(',',''))
print (price)
if price < dics[(keynum)] :
print ('success finding')
import mailling
sys.exit(1)
if now > until :
print ('time closing.')
sys.exit(1)
time.sleep(5)
driver.find_element_by_name('itemFullName').clear()
我希望这个消息来源不断发作,直到找到或结束时间。
但有时会发生错误,请按照捕获进行操作 “driver.find_element_by_xpath(log_but2).click()”段落出错。
我希望完美地消除这个错误 要么 在此错误情况下自动重试
我该怎么办?有人请帮助我