0

now i'm tring to search game items in trading board. So i made below source as a crawler

with (python 3.6 / Selenium / bs4 / Chromedrver)

here is my source

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()

i hope that this source works constantly till finding or time closing.

But Sometime the error occurs, follow the capture "driver.find_element_by_xpath(log_but2).click()" paragraph makes a error.

enter image description here

i want to elimate this error perfectly or to retry automatically in this error case

How can I do? someone please help me

  • 2
    Possible duplicate of [Selenium "selenium.common.exceptions.NoSuchElementException" when using Chrome](https://stackoverflow.com/questions/47993443/selenium-selenium-common-exceptions-nosuchelementexception-when-using-chrome) – undetected Selenium Feb 15 '18 at 05:01
  • You can try to use .driver.find_element_by_xpath(log_but2).submit().. bec it's inside form – Ankur Singh Feb 15 '18 at 08:32
  • 1
    @DebanjanB This seems to be a meaningful attempt. thanks i'll try it – Heart Aim DJ Feb 20 '18 at 07:22

0 Answers0