Python爬虫从入门到放弃 –Selenium爬取京东商品

编程入门 行业动态 更新时间:2024-10-11 01:10:55

Python<a href=https://www.elefans.com/category/jswz/34/1770264.html style=爬虫从入门到放弃 –Selenium爬取京东商品"/>

Python爬虫从入门到放弃 –Selenium爬取京东商品

参考文章:

写的第一个爬虫,还有参考别人的文章,请大神多多指教

 

#我是菜鸡,只是记录下我写的第一个爬虫
#欢迎各位大佬批评
# -*- coding: UTF-8 -*-
from selenium import  webdriver
import time
import csv#搜索商品
def SearchGoods(self):browser.find_element_by_xpath('//*[@id="key"]').send_keys(self)#搜索框输入商品browser.find_element_by_xpath('//*[@id="search"]/div/div[2]/button/i').click()#点击#滑到网页底部
def SwipPage():browser.execute_script('window.scrollTo(-1,document.body.scrollHeight)')#参考文章:
#获取源码
def GetSource():html = browser.page_source time.sleep(5)#分析数据 写入文件
def WriteCsv(): li_list = browser.find_elements_by_xpath('//*[@id="J_goodsList"]/ul/li')with open(&

更多推荐

Python爬虫从入门到放弃 –Selenium爬取京东商品

本文发布于:2024-02-12 00:22:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1684568.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:爬虫   京东   入门   商品   Python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!