Today, using Python and selenium to crawl dynamic data, mainly through the constant updating of the page to achieve data crawling, data to be crawled, such as
Source:
#-*-coding:utf-8-*-Import Time fromSeleniumImportWebdriverImportOSImportRe#introduction of Chromedriver.exeChromedriver ="C:/users/xuchunlin/appdata/local/google/chrome/application/chromedriver.exe"os.environ["Webdriver.chrome.driver"] =Chromedriverbrowser=Webdriver. Chrome (Chromedriver)#set the URL that the browser needs to openURL ="https://www.jin10.com/"#use the For loop to refresh the page endlessly, or refresh the page every once in a while forIinchRange (1,100000): browser.get (URL) result=Browser.page_source Gold_price=""Gold_price_change="" Try: Gold_price= Re.findall ('<div id= "xauusd_b" class= "Jin-price_value" style= ". *?" > (. *?) </div>', result) [0] Gold_price_change= Re.findall ('<div id= "xauusd_p" class= "Jin-price_value" style= ". *?" > (. *?) </div>', result) [0]except: Gold_pric="------"Gold_price_change="------" PrintGold_pricePrintGold_price_change Time.sleep (1)
Python Crawler Instances (8)--Crawl dynamic pages