1 Star 0 Fork 185

东方甲乙木 / Python爬虫

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
使用selenium爬取天猫数据.py 1.11 KB
一键复制 编辑 原始数据 按行查看 历史
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
from urllib.parse import quote
from pyquery import PyQuery as pq
broser=webdriver.Chrome()
wait=WebDriverWait(broser,10)
try:
a=input('请输入你要查找的商品:')
url='https://list.tmall.com/search_product.htm?q='+quote(a)
broser.get(url)
html=broser.page_source
doc=pq(html)
items=doc('.product-iWrap').items()
for i in items:
#print('i是:',i)
pro={
'店铺名':i.find('.productShop-name').text(),
'成交量':i.find('.productStatus').text(),
#'图片地址:':i.find('.productImg-wrap img').attr('src'),
'图片地址':i.attr('src'),
'内容':i.find('.productTitle a').text(),
'价格:':i.find('.productPrice').text()
}
print(pro)
except TimeoutException:
print('出错了')
finally:
broser.close()
Python
1
https://gitee.com/softwyy/python_reptilian.git
git@gitee.com:softwyy/python_reptilian.git
softwyy
python_reptilian
Python爬虫
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891