首先还是谷歌浏览器抓包对该网站数据进行分析,结果如下:
该网站地址:http://www.budejie.com/text
该网站数据都是通过html页面进行展示,网站url默认为第一页,http://www.budejie.com/text/2为第二页,以此类推
对网站的内容段子所处位置进行分析,发现段子内容都是在一个 a 标签中
坑还是有的,这是我第一次写的正则:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。content_list = re.findall(r'<a href="/detail-.*" rel="external nofollow" rel="external nofollow" rel="external nofollow" >(.+"j-r-list-c-desc">\s*<a href="/detail-.*" rel="external nofollow" rel="external nofollow" rel="external nofollow" >(.+"htmlcode">
import requests
import re
import json
class NeihanSpider(object):
"""内涵段子,百思不得其姐,正则爬取一页的数据"""
def __init__(self):
self.temp_url = 'http://www.budejie.com/text/{}' # 网站地址,给页码留个可替换的{}
self.headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36',
}
def pass_url(self, url): # 发送请求,获取响应
print(url)
response = requests.get(url, headers=self.headers)
return response.content.decode()
def get_first_page_content_list(self, html_str): # 提取第一页的数据
content_list = re.findall(r'<div class="j-r-list-c-desc">\s*<a href="/detail-.*" rel="external nofollow" rel="external nofollow" rel="external nofollow" >(.+?)</a>', html_str) # 非贪婪匹配
return content_list
def save_content_list(self, content_list):
with open('neihan.txt', 'a', encoding='utf-8') as f:
for content in content_list:
f.write(json.dumps(content, ensure_ascii=False))
f.write('\n') # 换行
print('成功保存一页!')
def run(self): # 实现主要逻辑
for i in range(20): # 只爬取前20页数据
# 1. 构造url
# 2. 发送请求,获取响应
html_str = self.pass_url(self.temp_url.format(i+1))
# 3. 提取数据
content_list = self.get_first_page_content_list(html_str)
# 4. 保存
self.save_content_list(content_list)
if __name__ == '__main__':
neihan = NeihanSpider()
neihan.run()
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
- 冯乔《回忆》人声低音炮[WAV+CUE]
- 张杰《要得》[FLAC/分轨][106.06MB]
- 周菲戈《顿悟》[320K/MP3][100.1MB]
- 周菲戈《顿悟》[FLAC/分轨][288.89MB]
- 罗文.1990-迟来的爱【世纪唱片】【WAV+CUE】
- 毛不易.2024-冒险精神【哇唧唧哇娱乐】【FLAC分轨】
- 杨乃文.2009-SELF-SLECTED(引进版)【SONY】【WAV+CUE】
- 张小英1988-金嗓子[引进磁带版][WAV+CUE]
- 王菲.2004-《环球巨星影音启示录2CD》环球[低速原抓WAV+CUE]
- 中国音乐地图之听见内蒙古马头琴潮尔音乐集2020[WAV分轨]
- 陈淑桦.1991-聪明糊涂心【滚石】【WAV+CUE】
- 吴奇隆.1994-奇而浓新歌+精丫华纳】【WAV+CUE】
- 群星.1996-宝丽金百感交集4CD【宝丽金】【WAV+CUE】
- 周震南《周震南“LOVE&DESIRE”演唱会LIVE辑 (Live)》[320K/MP3][219.43MB]
- 周震南《周震南“LOVE&DESIRE”演唱会LIVE辑 (Live)》[FLAC/分轨][641.64MB]