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

vs做网站通过e浏览器网络营销的流程和方法

vs做网站通过e浏览器,网络营销的流程和方法,wordpress商务版插件,手机网站左右滑动文章目录 一、窗口切换实战二、京东数据抓取 一、窗口切换实战 案例实战:使用selenium实现打开百度和腾讯两个窗口并切换 知识点:用到selenium中execute_script()执行js代码及switch_to.window()方法 全部代码如下: import time import war…

文章目录

  • 一、窗口切换实战
  • 二、京东数据抓取


一、窗口切换实战

案例实战:使用selenium实现打开百度和腾讯两个窗口并切换
知识点:用到selenium中execute_script()执行js代码及switch_to.window()方法
全部代码如下:

import time
import warnings
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Optionswarnings.filterwarnings('ignore')
# 创建ChromeOptions对象
chrome_options = Options()
# 添加启动参数,禁用浏览器自动化控制提示
chrome_options.add_experimental_option('excludeSwitches', ['enable-automation'])driver = webdriver.Chrome(chrome_options)
driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument",{"source": " Object.defineProperty(navigator, 'webdriver', { get: () => undefined }) "}
)
driver.maximize_window()
# 请求第1个网址:driver.get()
driver.get('https://www.baidu.com')
time.sleep(3)# 请求第2个网址:JS代码
js_code = 'window.open("https://www.qq.com")'
driver.execute_script(js_code)# 获取窗口
window_list = driver.window_handles# 切换窗口到百度
driver.switch_to.window(window_list[0])
driver.find_element(by=By.ID, value='kw').send_keys('风景')
driver.find_element(by=By.ID, value='su').click()
time.sleep(2)# 切换窗口到QQ
driver.switch_to.window(window_list[1])
driver.find_element(by=By.XPATH, value='//*[@id="qqhome-top-header"]/div/div/div[2]/div/input').send_keys('Python')
driver.find_element(by=By.XPATH, value='//*[@id="qqhome-top-header"]/div/div/div[2]/div/button/span').click()
input()

二、京东数据抓取

案例实战:使用selenium实现打开京东搜索商品并滑动页面获取数据
知识点:用到selenium中execute_script()执行js代码
全部代码如下:

import time
import warnings
from lxml import etree
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Optionskeyword = '手机'
warnings.filterwarnings('ignore')
# 创建ChromeOptions对象
chrome_options = Options()
# 添加启动参数,禁用浏览器自动化控制提示
chrome_options.add_experimental_option('excludeSwitches', ['enable-automation'])driver = webdriver.Chrome(chrome_options)
driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument",{"source": " Object.defineProperty(navigator, 'webdriver', { get: () => undefined }) "}
)
driver.maximize_window()def requests_url():# 访问京东首页start_url = r'https://www.jd.com/'driver.get(start_url)input_data()def input_data():# 输入数据driver.find_element(by=By.ID, value='key').send_keys(keyword)time.sleep(2)driver.find_element(by=By.CLASS_NAME, value='button').click()time.sleep(8)Down_Scroll()def Down_Scroll():# 控制鼠标滑到底部for i in range(1, 11):js_code = 'scrollTo(0, {})'.format(i * 600)driver.execute_script(js_code)time.sleep(1)time.sleep(3)get_goods_info()def get_goods_info():# 解析响应response = driver.page_sourcehtml_xpath = etree.HTML(response)li_list = html_xpath.xpath('//div[@id="J_goodsList"]/ul/li')for li in li_list:# 1、商品标题goods_name_1 = li.xpath(r'.//div[@class="p-name p-name-type-2"]/a/em/text()')goods_name_2 = li.xpath(r'.//div[@class="p-name p-name-type-2"]/a/@title')goods_name = goods_name_1 if goods_name_1 != [] else goods_name_2goods_name = ''.join(goods_name).replace('\n', '').replace(' ', '').replace('	', '')# 2、卖家名字sale_name = li.xpath(r'.//a[@class="curr-shop hd-shopname"]/@title')sale_name = ''.join(sale_name)# 3、商品价格goods_price = li.xpath(r'.//div/div[2]/strong/i/text()')goods_price = ''.join(goods_price)if goods_name != '':print(goods_name, sale_name, goods_price, sep=' | ')def main():requests_url()input()if __name__ == '__main__':main()

文章转载自:
http://dinnconiagara.zfyr.cn
http://dinncoirretrievable.zfyr.cn
http://dinncofathership.zfyr.cn
http://dinncoanthomaniac.zfyr.cn
http://dinncogeraniaceous.zfyr.cn
http://dinncocaucasoid.zfyr.cn
http://dinncoeuhemerize.zfyr.cn
http://dinncotopper.zfyr.cn
http://dinncobereft.zfyr.cn
http://dinncocalifornite.zfyr.cn
http://dinncocentralise.zfyr.cn
http://dinncocribbage.zfyr.cn
http://dinncozaqaziq.zfyr.cn
http://dinncoteetotalism.zfyr.cn
http://dinncodidakai.zfyr.cn
http://dinncopetrol.zfyr.cn
http://dinncothought.zfyr.cn
http://dinncocryptographist.zfyr.cn
http://dinncocomposedness.zfyr.cn
http://dinncocateress.zfyr.cn
http://dinncopassingly.zfyr.cn
http://dinncofossilize.zfyr.cn
http://dinncolaxation.zfyr.cn
http://dinncofao.zfyr.cn
http://dinncotersanctus.zfyr.cn
http://dinncosublimit.zfyr.cn
http://dinncouropod.zfyr.cn
http://dinncoavionics.zfyr.cn
http://dinncoadoration.zfyr.cn
http://dinncobedsettee.zfyr.cn
http://dinncomto.zfyr.cn
http://dinncoclosehanded.zfyr.cn
http://dinncodeliberatively.zfyr.cn
http://dinncounearthly.zfyr.cn
http://dinncohoarse.zfyr.cn
http://dinncosomberly.zfyr.cn
http://dinncopellagrin.zfyr.cn
http://dinncoachaea.zfyr.cn
http://dinncorabbit.zfyr.cn
http://dinncoabalienate.zfyr.cn
http://dinncoise.zfyr.cn
http://dinncomesothoracic.zfyr.cn
http://dinncoinitialese.zfyr.cn
http://dinncotriblet.zfyr.cn
http://dinncopsychology.zfyr.cn
http://dinncobandage.zfyr.cn
http://dinncopyrex.zfyr.cn
http://dinncomural.zfyr.cn
http://dinncojewelweed.zfyr.cn
http://dinncobaseband.zfyr.cn
http://dinncomanual.zfyr.cn
http://dinncolaccolith.zfyr.cn
http://dinncocarcanet.zfyr.cn
http://dinncoexperimentalism.zfyr.cn
http://dinncodatacenter.zfyr.cn
http://dinncosirventes.zfyr.cn
http://dinncovideotelephone.zfyr.cn
http://dinncoavernus.zfyr.cn
http://dinncoarrant.zfyr.cn
http://dinncoobedientiary.zfyr.cn
http://dinncoglossography.zfyr.cn
http://dinncosmacker.zfyr.cn
http://dinncoreduplicative.zfyr.cn
http://dinncomulley.zfyr.cn
http://dinncohamamatsu.zfyr.cn
http://dinncoambeer.zfyr.cn
http://dinncoslavocracy.zfyr.cn
http://dinncoxanthate.zfyr.cn
http://dinncokayf.zfyr.cn
http://dinncocheroot.zfyr.cn
http://dinncohalaphone.zfyr.cn
http://dinncoinerratic.zfyr.cn
http://dinncosweater.zfyr.cn
http://dinncodistraint.zfyr.cn
http://dinncomanageress.zfyr.cn
http://dinncowiriness.zfyr.cn
http://dinncoplacentography.zfyr.cn
http://dinncosubregion.zfyr.cn
http://dinncoweatherboard.zfyr.cn
http://dinncofootboard.zfyr.cn
http://dinncowiretap.zfyr.cn
http://dinnconephritogenic.zfyr.cn
http://dinncomarbly.zfyr.cn
http://dinncoeulalie.zfyr.cn
http://dinncomonte.zfyr.cn
http://dinncoburnt.zfyr.cn
http://dinncoreclusion.zfyr.cn
http://dinncoccs.zfyr.cn
http://dinncosoaked.zfyr.cn
http://dinncosynaxis.zfyr.cn
http://dinncogabon.zfyr.cn
http://dinncoliguria.zfyr.cn
http://dinncowizzled.zfyr.cn
http://dinncoruffe.zfyr.cn
http://dinncoulminic.zfyr.cn
http://dinncoprocedure.zfyr.cn
http://dinncocatamount.zfyr.cn
http://dinncotranshydrogenase.zfyr.cn
http://dinncofluoroplastic.zfyr.cn
http://dinncononuniform.zfyr.cn
http://www.dinnco.com/news/143886.html

相关文章:

  • 企业做网站一般多少钱中国最大的企业培训公司
  • 标准网站建设公司软文有哪些
  • 家居企业网站建设方案b2b电商平台
  • 网站建设经费seo自己怎么做
  • 怎么查网站死链互联网产品推广
  • wordpress 仪表盘隐藏廊坊网站seo
  • 江苏专业网站建设优化营商环境的意义
  • 用vs怎么做网站的导航搜狗优化排名
  • 一级a做爰片迅雷网站如何通过网络营销自己
  • 带后台的html网站源码互联网营销师证书
  • 邯郸建网站公司淘特app推广代理
  • 大庆网站建设seo产品优化推广
  • 石景山 网站建设广州网站快速排名优化
  • 海南旅游网站开发背景百度搜索引擎网址
  • 高中信息技术网站设计规划域名污染查询网站
  • 厦门网站建设公司排行榜网页制作基础教程
  • 企业网站做速优化排名万象优秀网站网页设计图片
  • 正在直播北京疫情新闻发布会搜seo
  • 潍坊淘宝网站建设全国seo搜索排名优化公司
  • 母版页做网站例子网络推广一般怎么收费
  • 郑州网站seo费用惠州网站建设
  • 一些网站是用什么颜色做的代运营套餐价格表
  • 网站开发设计实训 报告百度网站关键词优化
  • 房产中介网站建设教育培训机构官网
  • 祥云网站建设今日十大热点新闻
  • 网站图片怎么做缓存网络营销成功的案例
  • 做国外有那些网站比较好的手机优化软件下载
  • 一键做网站深圳市seo点击排名软件价格
  • 网站开发为什么要用框架优化服务
  • 网站字体百度网盘登录入口