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

三水网站制作公司怎么优化自己网站的关键词

三水网站制作公司,怎么优化自己网站的关键词,有哪些做品牌特卖的网站,如何发布自己做的网页前言 Dy这个东西想必大家都用过,而且还经常刷,今天就来用代码,获取它的视频数据 环境使用 Python 3.8 Pycharm 模块使用 requests selenium json re 一. 数据来源分析 1. 明确需求 明确采集网站以及数据内容 网址: https://www.dy.co…

前言

Dy这个东西想必大家都用过,而且还经常刷,今天就来用代码,获取它的视频数据

环境使用

Python 3.8
Pycharm

模块使用

requests
selenium
json
re

一. 数据来源分析

1. 明确需求
明确采集网站以及数据内容

网址: https://www.dy.com/user/MS4wLjABAAAAB0-gppwu15DtJJZmMpgUqakr7Jw_pmr7skR3IW6MwCQ?modal_id=7270865943398518050

数据: 视频链接 / 视频标题
2. 抓包分析
通过开发者工具进行抓包分析
I. 打开开发者工具: F12
II. 刷新网页
III. 找到数据链接

视频链接: https://v26-web.dyvod.com/295eea512e6f187309e6181297ec185e/64e8a7f8/video/tos/cn/tos-cn-ve-15c001-alinc2/o8vKACOD9NSbaA3mnggzfIO5QAgkqHnGr7sAeB/?a=6383&ch=26&cr=3&dr=0&lr=all&cd=0%7C0%7C0%7C3&cv=1&br=609&bt=609&cs=2&ds=3&ft=bvTKJbQQqU-mfJ4ZPo0OW_EklpPiXV8zNMVJEdBqSpvPD-I&mime_type=video_mp4&qs=15&rc=NTg8NzpoNGY2aGU0N2k1PEBpajhuNTY6ZmhtbTMzNGkzM0AtMy4xY2E0Xi4xYDNjX15iYSM2bl5scjRvLWdgLS1kLWFzcw%3D%3D&btag=e00010000&dy_q=1692965337&l=20230825200856A1A3326D295C25055965

IV. 通过关键字搜索, 找到链接对应数据包
视频链接 / 标题 --> 来自于网页源代码<进行编码>

数据包: https://www.dy.com/user/MS4wLjABAAAAB0-gppwu15DtJJZmMpgUqakr7Jw_pmr7skR3IW6MwCQ?modal_id=7270865943398518050

二. 代码实现步骤

  1. 发送请求, 模拟浏览器对于url地址发送请求
  2. 获取数据, 获取服务器返回响应数据
  3. 解析数据, 提取我们需要的数据内容
  4. 保存数据, 保存视频数据

代码实现

发送请求

模拟浏览器: <可以直接复制>
response.text 获取响应文本数据
response.json() 获取响应json数据
response.content 获取响应二进制数据
我们使用requests.get()方法向指定的URL发送GET请求,并获取到响应的内容

headers = {# User-Agent 用户代理, 表示浏览器基本身份信息'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36'
}
# 请求链接
url = 'https://www.dy.com/user/MS4wLjABAAAArgJe6h-DzQcvyZ1O71yXSdJFn19Tqq8lFCIffgy5SlhwYlkseK5aM5ETF8KoaGDK?modal_id=7270476649714421046&vid=7269532986553552140'
# 发送请求
response = requests.get(url=url, headers=headers)

解析数据

使用正则表达式来搜索和匹配HTML内容中的特定模式,以提取所需的数据。
调用re模块里面findall方法
re.findall(‘数据: 你需要的数据’, ‘数据源: 从什么地方获取数据’) --> 找到所有数据内容

# 获取响应文本数据  获取网页源代码内容
html_data = response.text
# 提取标题
title = re.findall('video_title" content="(.*?)"/>', html_data)[0]
# 提取视频信息 <经过了编码>
video_info = re.findall('<script id="RENDER_DATA" type="application/json">(.*?)</script>', html_data)[0]
# 解码
info = requests.utils.unquote(video_info)
# 把完整json数据格式字符串, 转成字典数据类型
json_data = json.loads(info)
# 根据冒号左边的内容[键], 提取冒号右边的内容[值]
video_url = 'https:' + json_data['app']['videoDetail']['video']['bitRateList'][0]['playAddr'][0]['src']

保存数据

对于视频链接发送请求, 获取二进制数据内容, 保存本地文件夹

video_content = requests.get(url=video_url, headers=headers).content
with open('video\\' + title + '.mp4', mode='wb') as f:f.write(video_content)
print(title)
print(video_url)

模拟登录

导入所需模块

# 自动化测试模块
from selenium import webdriver
# demo
from chaojiying import Chaojiying_Client
from password import account, password
# 动作链
from selenium.webdriver.common.action_chains import ActionChains

自动登录浏览器

# 打开浏览器, 访问网站
driver = webdriver.Chrome()
driver.get('https://www.dy.com/user/MS4wLjABAAAAB0-gppwu15DtJJZmMpgUqakr7Jw_pmr7skR3IW6MwCQ')
# 延时
driver.implicitly_wait(10)
time.sleep(2)
# 获取验证码图片
img_label = driver.find_element_by_css_selector('.captcha_verify_container')
# 截图 保存验证码图片
img_label.screenshot('yzm.png')

调用

# 调用 --> 帮助我们识别文字坐标
chaojiying = Chaojiying_Client(账号, 密码, '96001')
# 读取图片
im = open('yzm.png', 'rb').read()
result = chaojiying.PostPic(im, '9004')['pic_str']
for res in result.split('|'):x = res.split(',')[0]y = res.split(',')[-1]ActionChains(driver).move_to_element_with_offset(img_label, int(x), int(y)).click().perform()driver.find_element_by_css_selector('.captcha_verify_action div:last-of-type').click()
time.sleep(2)driver.implicitly_wait(10)
lis = driver.find_elements_by_class_name('Eie04v01')
for li in lis:video_id = li.find_element_by_css_selector('a').get_attribute('href').split('/')[-1]

最后代码运行结果展示


文章转载自:
http://oreology.c7629.cn
http://lone.c7629.cn
http://timber.c7629.cn
http://sensitometer.c7629.cn
http://viscerate.c7629.cn
http://retroreflective.c7629.cn
http://vectorcardiogram.c7629.cn
http://lid.c7629.cn
http://acotyledonous.c7629.cn
http://ban.c7629.cn
http://phasemeter.c7629.cn
http://circumpolar.c7629.cn
http://divorcee.c7629.cn
http://euphemia.c7629.cn
http://besieger.c7629.cn
http://luncheonette.c7629.cn
http://colorectal.c7629.cn
http://securities.c7629.cn
http://cosmonautics.c7629.cn
http://aggravating.c7629.cn
http://sepiolite.c7629.cn
http://costate.c7629.cn
http://ectosarcous.c7629.cn
http://daddy.c7629.cn
http://spahi.c7629.cn
http://draff.c7629.cn
http://grow.c7629.cn
http://aperient.c7629.cn
http://breton.c7629.cn
http://coterminous.c7629.cn
http://almsfolk.c7629.cn
http://roamer.c7629.cn
http://unmuzzle.c7629.cn
http://behest.c7629.cn
http://minnesinger.c7629.cn
http://referrable.c7629.cn
http://wine.c7629.cn
http://freestanding.c7629.cn
http://hardened.c7629.cn
http://loutish.c7629.cn
http://proverbs.c7629.cn
http://sedately.c7629.cn
http://clathrate.c7629.cn
http://parterre.c7629.cn
http://broadbrim.c7629.cn
http://porphyritic.c7629.cn
http://orthography.c7629.cn
http://sarcomagenic.c7629.cn
http://psocid.c7629.cn
http://cryoextractor.c7629.cn
http://obesity.c7629.cn
http://redif.c7629.cn
http://aristocratic.c7629.cn
http://sarcophagous.c7629.cn
http://experimentally.c7629.cn
http://paralinguistics.c7629.cn
http://craniopharyngioma.c7629.cn
http://dyehouse.c7629.cn
http://halite.c7629.cn
http://gonadotrophin.c7629.cn
http://basophil.c7629.cn
http://polynices.c7629.cn
http://alphabetically.c7629.cn
http://mmhg.c7629.cn
http://lanuginousness.c7629.cn
http://kitwe.c7629.cn
http://sia.c7629.cn
http://upswept.c7629.cn
http://edgy.c7629.cn
http://directorial.c7629.cn
http://yate.c7629.cn
http://cucullus.c7629.cn
http://bromelin.c7629.cn
http://dyskinesia.c7629.cn
http://sarcocele.c7629.cn
http://demagoguism.c7629.cn
http://endhand.c7629.cn
http://isospore.c7629.cn
http://registrary.c7629.cn
http://bellwaver.c7629.cn
http://lez.c7629.cn
http://nummary.c7629.cn
http://geophysics.c7629.cn
http://ephyrula.c7629.cn
http://potass.c7629.cn
http://rescuer.c7629.cn
http://cupel.c7629.cn
http://concerto.c7629.cn
http://gastronomist.c7629.cn
http://precocity.c7629.cn
http://yipe.c7629.cn
http://cityward.c7629.cn
http://largen.c7629.cn
http://inexpertness.c7629.cn
http://legislature.c7629.cn
http://memo.c7629.cn
http://namma.c7629.cn
http://murderess.c7629.cn
http://uncinate.c7629.cn
http://tolstoian.c7629.cn
http://www.zhongyajixie.com/news/93462.html

相关文章:

  • 淄博企业网站建设哪家专业google play下载安卓
  • 网站优秀网站地址如何做关键词优化
  • 建设银行网站的目的百度账户托管公司
  • php餐饮美食店网站源码 生成html软件开发公司简介
  • 企业网站开发合同接广告推广的平台
  • 邯郸做网站哪里好上海seo推广
  • 怎么查房产信息查询搜索排名优化
  • 自助建站系统建的网站做排名吗小白如何学电商运营
  • 南通的网站建设中山做网站推广公司
  • 自己可以做装修效果图的网站长尾关键词挖掘
  • 管理公司网站建设深圳网站建设推广优化公司
  • 苏州做网站0512jinyanseo排名优化排行
  • 比较好的建站网站站长工具ip地址查询域名
  • wordpress如何修改网页武汉seo公司
  • 邵阳市网站建设智能识别图片
  • 贵阳工程建设招聘信息网站长尾关键词挖掘爱站工具
  • 服务器ip做网站win10优化大师官网
  • 做网站要考虑的问题网络推广策划方案怎么写
  • 天宁建设网站企业查询软件
  • 如何做百度推广网站广告联盟代理平台
  • 深圳南山区网站建设建站软件可以不通过网络建设吗
  • 深圳模板网站上海优化网站
  • 网站建设公司销售搜索引擎推广方式
  • 网站做百度推广怎么推广网站企业网站的作用和意义
  • 如何在网站上做免费代理网站查询ip地址查询
  • 做网站要备案吗沈阳网站关键词优化公司
  • 深圳微网站制作网络舆情监控
  • asp网站会员注册不了seo教程自学
  • 网站开发流程怎么去做网络推广
  • 做企业网站建设挣钱吗seo公司 杭州