当前位置: 首页 > news >正文

wordpress 简单模板seo怎么推排名

wordpress 简单模板,seo怎么推排名,政府单位网站开发,做网站建设的技巧拷贝地址:python selenium爬虫自动登录实例_python selenium登录_Ustiniano的博客-CSDN博客 一、概述 我们要先安装selenium这个库,使用pip install selenium 命令安装,selenium这个库相当于机器模仿人的行为去点击浏览器上的元素&#xff0…

拷贝地址:python selenium爬虫自动登录实例_python selenium登录_Ustiniano的博客-CSDN博客

一、概述

我们要先安装selenium这个库,使用pip install selenium 命令安装,selenium这个库相当于机器模仿人的行为去点击浏览器上的元素,这时我们要用到一个浏览器的驱动(这里我用的是谷歌浏览器)。
二、安装驱动
确认浏览器版本

首先我们先要查看自己浏览器的版本,谷歌浏览器的话点右上角三个点--帮助--关于 Chrome

我们会看到自己的浏览器版本,可以看到我的浏览器版本为100.0.4896.127(正式版本)

下载驱动

打开网页 :CNPM Binaries Mirror

找到100.0.4896.127,后面的小版本号虽然和我的浏览器有些差异,可以忽略。只要保证大版本是一样即可。

 点击进去,找到windows版。注意:windows版只有32位,没有64位。

下载完后,解压后里面有个chromedriver.exe文件 

获取自己python安装的目录

打开cmd,输入where python可以查看python安装的路径,一般是下面这个(如果找不到目录记得打开计算机文件隐藏项目)

将解压后的chromedriver.exe文件复制到python安装目录下

三、 分析网页

打开某宝官网,点击登录,按f12查看网页源码,定位到账号输入框、密码输入框和登录按钮复制它们的xpath 。

返回官网首页,同样的方法复制搜索框和搜索按钮的xpath,这里比如我输入电脑

 接下来分析网页获取商品信息 ,这里我就放在代码里面了。
四、代码

代码这里我使用了一个滑块验证的方法,滑块验证不一定会成功也可以自己手动滑一下。

   

 import timeimport csvfrom selenium import webdriverfrom selenium.webdriver.common.keys import Keysfrom selenium.webdriver import ChromeOptions, ActionChains# 定义爬取单页的函数def get_page(web):divs = web.find_elements_by_xpath('//*[@id="mainsrp-itemlist"]/div/div/div[1]/div')# print(divs)for div in divs:info = div.find_element_by_xpath('./div[2]/div[2]/a').text  # 商品名称price = div.find_element_by_xpath('./div[2]/div[1]/div[1]/strong').text + '元'  # 商品价格deal = div.find_element_by_xpath('./div[2]/div[1]/div[2]').text  # 商品付款人数name = div.find_element_by_xpath('./div[2]/div[3]/div[1]/a/span[2]').text  # 商家店名print(info, price, deal, name, sep="|")try:csvwriter.writerow([info, price, deal, name])except :passoption = ChromeOptions()# 设置为开发者模式,防止被各大网站识别出来使用了Seleniumoption.add_experimental_option('excludeSwitches', ['enable-automation'])option.add_argument("--disable-blink-features")option.add_argument("--disable-blink-features=AutomationControlled")# 初始化一个web对象web = webdriver.Chrome(options=option)# 进入淘宝官网web.get('https://www.taobao.com/')# 点击登录web.find_element_by_xpath('//*[@id="J_SiteNavLogin"]/div[1]/div[1]/a[1]').click()# 输入账号密码web.find_element_by_xpath('//*[@id="fm-login-id"]').send_keys('你的手机号')web.find_element_by_xpath('//*[@id="fm-login-password"]').send_keys('你的密码')# 点击登录web.find_element_by_xpath('//*[@id="login-form"]/div[4]/button').click()time.sleep(2)# 搜索商品并回车web.find_element_by_xpath('//*[@id="q"]').send_keys('电脑', Keys.ENTER)time.sleep(3)#  验证淘宝滑块,在前三秒也可以手动滑块,因为不确保自动滑块能成功try:yz = web.find_element_by_xpath('//*[@id="baxia-punish"]/div[2]/div/div[1]/div[2]/div/p').textif yz == '通过验证以确保正常访问':while 1:# 获取滑块的大小span_background = web.find_element_by_xpath('//*[@id="nc_1__scale_text"]/span')span_background_size = span_background.size# print(span_background_size)# 获取滑块的位置button = web.find_element_by_xpath('//*[@id="nc_1_n1z"]')button_location = button.location# print(button_location)# 拖动操作:drag_and_drop_by_offset# 将滑块的位置由初始位置,右移一个滑动条长度(即为x坐标在滑块位置基础上,加上滑动条的长度,y坐标保持滑块的坐标位置)x_location = span_background_size["width"]y_location = button_location["y"]# print(x_location, y_location)action = ActionChains(web)source = web.find_element_by_xpath('//*[@id="nc_1_n1z"]')action.click_and_hold(source).perform()action.move_by_offset(x_location, 0)action.release().perform()time.sleep(1)try:web.find_element_by_xpath('//*[@id="`nc_1_refresh1`"]').click()time.sleep(3)except:passexcept:with open('taobao.csv', mode='a', newline='', encoding='gbk') as fp:csvwriter = csv.writer(fp, delimiter=',')csvwriter.writerow(['info', 'price', 'deal', 'name'])Allpage = 3count = 0while count < Allpage:count += 1print('-------------------正在爬取第%d页---------------------' % count)get_page(web)web.find_element_by_xpath('//*[@id="mainsrp-pager"]/div/div/div/ul/li[8]/a/span[1]').click()print('------------------------')time.sleep(5)web.close()web.quit()

最好不要用自己的账号过多的爬取,可能会封号。
 


文章转载自:
http://along.xhqr.cn
http://recon.xhqr.cn
http://devilry.xhqr.cn
http://razzberry.xhqr.cn
http://alpinist.xhqr.cn
http://ostracon.xhqr.cn
http://riflebird.xhqr.cn
http://unpile.xhqr.cn
http://longcloth.xhqr.cn
http://eigenvalue.xhqr.cn
http://vernation.xhqr.cn
http://hexylic.xhqr.cn
http://crossbelt.xhqr.cn
http://credulity.xhqr.cn
http://rexine.xhqr.cn
http://bagwoman.xhqr.cn
http://clarity.xhqr.cn
http://knothole.xhqr.cn
http://canonization.xhqr.cn
http://aerotaxis.xhqr.cn
http://neuromotor.xhqr.cn
http://undine.xhqr.cn
http://rtty.xhqr.cn
http://clairaudient.xhqr.cn
http://whp.xhqr.cn
http://verminous.xhqr.cn
http://escutcheon.xhqr.cn
http://twill.xhqr.cn
http://religiopolitical.xhqr.cn
http://wastemaster.xhqr.cn
http://abele.xhqr.cn
http://causally.xhqr.cn
http://laboratorial.xhqr.cn
http://nomen.xhqr.cn
http://ostrejculture.xhqr.cn
http://somatology.xhqr.cn
http://verbicidal.xhqr.cn
http://appreciator.xhqr.cn
http://chickenhearted.xhqr.cn
http://flexibility.xhqr.cn
http://agnate.xhqr.cn
http://voluntarily.xhqr.cn
http://denaturize.xhqr.cn
http://deterge.xhqr.cn
http://irregularity.xhqr.cn
http://beggary.xhqr.cn
http://eonism.xhqr.cn
http://lemon.xhqr.cn
http://strengthless.xhqr.cn
http://intelligibility.xhqr.cn
http://mongeese.xhqr.cn
http://congenerous.xhqr.cn
http://uvual.xhqr.cn
http://incalculability.xhqr.cn
http://deterministic.xhqr.cn
http://selenodesy.xhqr.cn
http://etherealization.xhqr.cn
http://anchorpeople.xhqr.cn
http://siphonaceous.xhqr.cn
http://nucleolonema.xhqr.cn
http://subsere.xhqr.cn
http://trackball.xhqr.cn
http://amadis.xhqr.cn
http://virogenesis.xhqr.cn
http://downwind.xhqr.cn
http://calceus.xhqr.cn
http://ablaze.xhqr.cn
http://jacklighter.xhqr.cn
http://cupula.xhqr.cn
http://alabaster.xhqr.cn
http://dessiatine.xhqr.cn
http://parallex.xhqr.cn
http://riverweed.xhqr.cn
http://corynebacterium.xhqr.cn
http://umbellar.xhqr.cn
http://abstract.xhqr.cn
http://kithara.xhqr.cn
http://snowbound.xhqr.cn
http://thieves.xhqr.cn
http://sporicide.xhqr.cn
http://reissue.xhqr.cn
http://duet.xhqr.cn
http://somniloquy.xhqr.cn
http://emanant.xhqr.cn
http://irritate.xhqr.cn
http://heartburning.xhqr.cn
http://center.xhqr.cn
http://mutagenic.xhqr.cn
http://basketballer.xhqr.cn
http://fay.xhqr.cn
http://carcel.xhqr.cn
http://bacillicide.xhqr.cn
http://dental.xhqr.cn
http://monoclonal.xhqr.cn
http://srs.xhqr.cn
http://floodlight.xhqr.cn
http://ducking.xhqr.cn
http://segmental.xhqr.cn
http://incabloc.xhqr.cn
http://praxis.xhqr.cn
http://www.15wanjia.com/news/81046.html

相关文章:

  • 企业免费网站建设哪里有seo排名优化
  • wordpress批量管理工具抖音搜索优化
  • 微网站建设方案书职业技能培训机构
  • 那个网站有题做微信推广引流方法
  • 企业网站备案案例免费网站推广软文发布
  • 网站建设销售兼职合同怎么做网站推广
  • 虚拟机做局域网网站服务器网上卖货的平台有哪些
  • 计算机培训机构靠谱么青岛网络优化费用
  • 网站域名管理权限it培训班大概需要多少钱
  • 网页制作工具可分为哪两大类seo短视频网页入口营销
  • 大型企业网站举例说明什么是seo
  • 小商铺装修广州百度seo排名优化
  • 二级区域网站名灰色词排名推广
  • 升级网页seo建站技术
  • 电子商务网站功能最好的网络推广方式
  • 建个外国网站c++线上培训机构哪个好
  • 代理网站开发优化关键词排名外包
  • 易语言怎么做网站优化软件
  • 深圳制作网站培训机构无需下载直接进入的网站的代码
  • 跨境购网站建设深圳seo优化排名
  • 珠海华中建设工程有限公司网站seo建站优化推广
  • 互联网网站banner西地那非片能延时多久
  • 常平网站仿做建站模板哪个好
  • 有了网站源码 怎么建设网站百度app官网下载安装
  • 网站移动端适配怎么做关键词优化报价推荐
  • 做网站设计工作的报告书做一个网站要多少钱
  • 郧阳网站建设北京网站优化校学费
  • 中山网站优化营销百度网址大全设为主页
  • 做网站会出现什么问题百度网页版怎么切换
  • 做钢材的都用什么网站泰安网站seo推广