Scrape Center爬虫平台之spa7案例

编程入门 行业动态 更新时间:2024-10-08 18:38:47

Scrape Center<a href=https://www.elefans.com/category/jswz/34/1770264.html style=爬虫平台之spa7案例"/>

Scrape Center爬虫平台之spa7案例


其实我并没有真懂,其实我觉得直接复制人家的main.js就得了。简单、干脆、直接,我也就打了几个断点观察一下就撤了。如果直接上无脑selenium,name会出现乱码。

import requests
import re
def getHTMLText(url):try:r=requests.get(url,timeout=30)r.raise_for_status()r.encoding='utf-8'return r.text[17:2000]except:pass
url="/js/main.js"
html=getHTMLText(url)
print(html)
pattern=r"(?<=name: ')(.+?)(?=',)"
name_list=re.findall(pattern,html)
print(name_list)

运行结果:
{
name: ‘凯文-杜兰特’,
image: ‘durant.png’,
birthday: ‘1988-09-29’,
height: ‘208cm’,
weight: ‘108.9KG’
}, {
name: ‘勒布朗-詹姆斯’,
image: ‘james.png’,
birthday: ‘1984-12-30’,
height: ‘206cm’,
weight: ‘113.4KG’
}, {
name: ‘斯蒂芬-库里’,
image: ‘curry.png’,
birthday: ‘1988-03-14’,
height: ‘191cm’,
weight: ‘83.9KG’
}, {
name: ‘詹姆斯-哈登’,
image: ‘harden.png’,
birthday: ‘1989-08-26’,
height: ‘196cm’,
weight: ‘99.8KG’
}, {
name: ‘扬尼斯-安特托昆博’,
image: ‘antetokounmpo.png’,
birthday: ‘1994-12-06’,
height: ‘211cm’,
weight: ‘109.8KG’
}, {
name: ‘拉塞尔-威斯布鲁克’,
image: ‘westbrook.png’,
birthday: ‘1988-11-12’,
height: ‘191cm’,
weight: ‘90.7KG’
}, {
name: ‘凯里-欧文’,
image: ‘irving.png’,
birthday: ‘1992-03-23’,
height: ‘188cm’,
weight: ‘88.5KG’
}, {
name: ‘安东尼-戴维斯’,
image: ‘davis.png’,
birthday: ‘1993-03-11’,
height: ‘208cm’,
weight: ‘114.8KG’
}, {
name: ‘乔尔-恩比德’,
image: ‘embiid.png’,
birthday: ‘1994-03-16’,
height: ‘213cm’,
weight: ‘127.0KG’
}, {
name: ‘克雷-汤普森’,
image: ‘thompson.png’,
birthday: ‘1990-02-08’,
height: ‘198cm’,
weight: ‘97.5KG’
}, {
name: ‘考瓦伊-莱昂纳德’,
image: ‘leonard.png’,
birthday: ‘1991-06-29’,
height: ‘201cm’,
weight: ‘102.1KG’
}, {
name: ‘达米安-利拉德’,
image: ‘lillard.png’,
birthday: ‘1990-07-15’,
height: ‘188cm’,
weight: ‘88.5KG’
}, {
name: ‘卡梅罗-安东尼’,
image: ‘anthony.png’,
birthday: ‘1984-05-29’,
height: ‘203cm’,
weight: ‘108KG’
}, {
name: ‘尼科拉-约基奇’,
image: ‘jokic.png’,
birthday: ‘1995-02-19’,
height: ‘213cm’,
weight: ‘128.8KG’
}, {
name: ‘卡尔-安东尼-唐斯’,
image: ‘towns.png’,
birthday: ‘1995-11-15’,
height: ‘211cm’,
weight: ‘112.5KG’
}, {
name: ‘克里斯-保罗’,
image: ‘paul.png’,
birthday: ‘1985-05-06’,
height: ‘185cm’,
weight: ‘79.4KG’
}
[‘凯文-杜兰特’, ‘勒布朗-詹姆斯’, ‘斯蒂芬-库里’, ‘詹姆斯-哈登’, ‘扬尼斯-安特托昆博’, ‘拉塞尔-威斯布鲁克’, ‘凯里-欧文’, ‘安东尼-戴维斯’, ‘乔尔-恩比德’, ‘克雷-汤普森’, ‘考瓦伊-莱昂纳德’, ‘达米安-利拉德’, ‘卡梅罗-安东尼’, ‘尼科拉-约基奇’, ‘卡尔-安东尼-唐斯’, ‘克里斯-保罗’]

更多推荐

Scrape Center爬虫平台之spa7案例

本文发布于:2024-02-07 06:27:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1754388.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:爬虫   案例   平台   Scrape   Center

发布评论

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

>www.elefans.com

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