當(dāng)前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
Python PhantomJS 爬虫 示例
生活随笔
收集整理的這篇文章主要介紹了
Python PhantomJS 爬虫 示例
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
from selenium import webdriver
# 請求url url = "https://auctions.freemansauction.com/auction-lot-detail/A%2Dplatinum%2Dand%2Ddiamond%2Dlorgnette%2C/1593+++++++2+/++989817"mydriver = webdriver.PhantomJS()
try:
mydriver.get(url)
result = mydriver.page_source.encode('utf8')
except:
result = mydriver.get(url)
if 'language="javascript">setTimeout' in result:
result = mydriver.get(url)
result_repalce = replace(result)
item_desc = re.findall('<div class="lot_detail_description">(.*?)</div><hr>',result_repalce)[0]
estimate_price = re.findall('<br> <b>Estimate(.*?)</b><br><br>',result_repalce)[0]
print item_desc print estimate_price
# 請求url url = "https://auctions.freemansauction.com/auction-lot-detail/A%2Dplatinum%2Dand%2Ddiamond%2Dlorgnette%2C/1593+++++++2+/++989817"mydriver = webdriver.PhantomJS()
try:
mydriver.get(url)
result = mydriver.page_source.encode('utf8')
except:
result = mydriver.get(url)
if 'language="javascript">setTimeout' in result:
result = mydriver.get(url)
result_repalce = replace(result)
item_desc = re.findall('<div class="lot_detail_description">(.*?)</div><hr>',result_repalce)[0]
estimate_price = re.findall('<br> <b>Estimate(.*?)</b><br><br>',result_repalce)[0]
print item_desc print estimate_price
?
總結(jié)
以上是生活随笔為你收集整理的Python PhantomJS 爬虫 示例的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C# 读取TXT文本数据 添加到数据库
- 下一篇: Test2 unit4