推荐脚本+分页处理
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"execution_count": 19,
|
||||
"id": "948be230",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -41,7 +41,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"execution_count": 20,
|
||||
"id": "31a8a0dd",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -49,9 +49,9 @@
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\u001b[32m2025-11-20 15:39:21.410\u001b[0m | \u001b[1mINFO \u001b[0m | \u001b[36mcrawler.BaseCrawler\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m71\u001b[0m - \u001b[1m初始化爬虫: XhwCrawler\u001b[0m\n",
|
||||
"\u001b[32m2025-11-20 15:39:22.502\u001b[0m | \u001b[1mINFO \u001b[0m | \u001b[36mcrawler.xhw.XhwCrawler\u001b[0m:\u001b[36m_init_driver\u001b[0m:\u001b[36m20\u001b[0m - \u001b[1mChrome浏览器初始化成功\u001b[0m\n",
|
||||
"\u001b[32m2025-11-20 15:39:22.502\u001b[0m | \u001b[1mINFO \u001b[0m | \u001b[36mcrawler.xhw.XhwCrawler\u001b[0m:\u001b[36m_init_driver\u001b[0m:\u001b[36m24\u001b[0m - \u001b[1m访问主页获取初始Cookie\u001b[0m\n"
|
||||
"\u001b[32m2025-11-20 16:06:16.802\u001b[0m | \u001b[1mINFO \u001b[0m | \u001b[36mcrawler.BaseCrawler\u001b[0m:\u001b[36m__init__\u001b[0m:\u001b[36m71\u001b[0m - \u001b[1m初始化爬虫: XhwCrawler\u001b[0m\n",
|
||||
"\u001b[32m2025-11-20 16:06:17.899\u001b[0m | \u001b[1mINFO \u001b[0m | \u001b[36mcrawler.xhw.XhwCrawler\u001b[0m:\u001b[36m_init_driver\u001b[0m:\u001b[36m20\u001b[0m - \u001b[1mChrome浏览器初始化成功\u001b[0m\n",
|
||||
"\u001b[32m2025-11-20 16:06:17.900\u001b[0m | \u001b[1mINFO \u001b[0m | \u001b[36mcrawler.xhw.XhwCrawler\u001b[0m:\u001b[36m_init_driver\u001b[0m:\u001b[36m24\u001b[0m - \u001b[1m访问主页获取初始Cookie\u001b[0m\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -61,7 +61,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"execution_count": 21,
|
||||
"id": "e5a6e91c",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -76,7 +76,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"execution_count": 22,
|
||||
"id": "7e0f56fa",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -86,45 +86,35 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"execution_count": 26,
|
||||
"id": "47327ebf",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#crawler.parse_xh_news_detail(\"https://www.news.cn/politics/leaders/20250224/5384be3d47c643b3a68e3bb724656152/c.html\")\n",
|
||||
"# crawler.parse_xh_news_detail(\"https://www.news.cn/politics/leaders/20240207/2819fe60663140eab9599581dcae8c1e/c.html\") #视频"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"id": "fa359d5b",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"\u001b[32m2025-11-20 15:45:21.322\u001b[0m | \u001b[1mINFO \u001b[0m | \u001b[36mcrawler.xhw.XhwCrawler\u001b[0m:\u001b[36mcommend\u001b[0m:\u001b[36m44\u001b[0m - \u001b[1m轮播图新闻url: 5\u001b[0m\n",
|
||||
"\u001b[32m2025-11-20 15:45:21.483\u001b[0m | \u001b[1mINFO \u001b[0m | \u001b[36mcrawler.xhw.XhwCrawler\u001b[0m:\u001b[36mcommend\u001b[0m:\u001b[36m54\u001b[0m - \u001b[1m聚焦新闻url: 21\u001b[0m\n",
|
||||
"\u001b[32m2025-11-20 15:45:22.214\u001b[0m | \u001b[1mINFO \u001b[0m | \u001b[36mcrawler.xhw.XhwCrawler\u001b[0m:\u001b[36mcommend\u001b[0m:\u001b[36m44\u001b[0m - \u001b[1m轮播图新闻url: 7\u001b[0m\n",
|
||||
"\u001b[32m2025-11-20 15:45:23.134\u001b[0m | \u001b[1mINFO \u001b[0m | \u001b[36mcrawler.xhw.XhwCrawler\u001b[0m:\u001b[36mcommend\u001b[0m:\u001b[36m54\u001b[0m - \u001b[1m聚焦新闻url: 124\u001b[0m\n",
|
||||
"\u001b[32m2025-11-20 15:45:23.135\u001b[0m | \u001b[1mINFO \u001b[0m | \u001b[36mcrawler.xhw.XhwCrawler\u001b[0m:\u001b[36mcommend\u001b[0m:\u001b[36m55\u001b[0m - \u001b[1m获取到新闻url:157\u001b[0m\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"ResultDomain(code=0, message='', success=True, data=None, dataList=[])"
|
||||
"NewsItem(title='全国精神文明建设表彰大会在京召开', contentRows=[{'tag': 'img', 'content': \"<img src='https://www.news.cn/photo/20250523/9fc5e377b19047918dfe0eca2aad5c67/202505239fc5e377b19047918dfe0eca2aad5c67_202505232bbfd057329e448b9540fc5dbf050283.jpg' />\"}, {'tag': 'p', 'content': '<p>\\u2003\\u20035月23日,全国精神文明建设表彰大会在北京召开。中央宣传思想文化工作领导小组决定,授予202个城市(区)全国文明城市(区)称号,授予3316个村镇全国文明村镇称号,授予4688个单位全国文明单位称号,授予798户家庭全国文明家庭称号,授予890所学校全国文明校园称号;授予60名(组)同志第九届全国道德模范荣誉称号,授予239名(组)同志第九届全国道德模范提名奖。</p>'}, {'tag': 'p', 'content': '<p>\\u2003\\u2003新华社记者 翟健岚 摄</p>'}, {'tag': 'img', 'content': \"<img src='https://www.news.cn/photo/20250523/9fc5e377b19047918dfe0eca2aad5c67/202505239fc5e377b19047918dfe0eca2aad5c67_20250523ead9d290ee4c45928fc7ca35e227727b.jpg' />\"}, {'tag': 'p', 'content': '<p>\\u2003\\u20035月23日,全国精神文明建设表彰大会在北京召开。中央宣传思想文化工作领导小组决定,授予202个城市(区)全国文明城市(区)称号,授予3316个村镇全国文明村镇称号,授予4688个单位全国文明单位称号,授予798户家庭全国文明家庭称号,授予890所学校全国文明校园称号;授予60名(组)同志第九届全国道德模范荣誉称号,授予239名(组)同志第九届全国道德模范提名奖。</p>'}, {'tag': 'p', 'content': '<p>\\u2003\\u2003新华社记者 翟健岚 摄</p>'}, {'tag': 'img', 'content': \"<img src='https://www.news.cn/photo/20250523/9fc5e377b19047918dfe0eca2aad5c67/202505239fc5e377b19047918dfe0eca2aad5c67_20250523971c4e94467b451c93cd4810992e2025.jpg' />\"}, {'tag': 'p', 'content': '<p>\\u2003\\u20035月23日,全国精神文明建设表彰大会在北京召开。中央宣传思想文化工作领导小组决定,授予202个城市(区)全国文明城市(区)称号,授予3316个村镇全国文明村镇称号,授予4688个单位全国文明单位称号,授予798户家庭全国文明家庭称号,授予890所学校全国文明校园称号;授予60名(组)同志第九届全国道德模范荣誉称号,授予239名(组)同志第九届全国道德模范提名奖。</p>'}, {'tag': 'p', 'content': '<p>\\u2003\\u2003新华社记者 翟健岚 摄</p>'}, {'tag': 'img', 'content': \"<img src='https://www.news.cn/photo/20250523/9fc5e377b19047918dfe0eca2aad5c67/202505239fc5e377b19047918dfe0eca2aad5c67_20250523cf0f3bf322184d339a91049891f265bb.jpg' />\"}, {'tag': 'p', 'content': '<p>\\u2003\\u20035月23日,全国精神文明建设表彰大会在北京召开。中央宣传思想文化工作领导小组决定,授予202个城市(区)全国文明城市(区)称号,授予3316个村镇全国文明村镇称号,授予4688个单位全国文明单位称号,授予798户家庭全国文明家庭称号,授予890所学校全国文明校园称号;授予60名(组)同志第九届全国道德模范荣誉称号,授予239名(组)同志第九届全国道德模范提名奖。</p>'}, {'tag': 'p', 'content': '<p>\\u2003\\u2003新华社记者 翟健岚 摄</p>'}], url='https://www.news.cn/photo/20250523/9fc5e377b19047918dfe0eca2aad5c67/c.html', viewCount=None, publishTime='2025-05-23 18:33:10', author=None, source='新华网', category=None, executeStatus=0, executeMessage=None)"
|
||||
]
|
||||
},
|
||||
"execution_count": 17,
|
||||
"execution_count": 26,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"crawler.commend()"
|
||||
"#crawler.parse_xh_news_detail(\"https://www.news.cn/politics/leaders/20250224/5384be3d47c643b3a68e3bb724656152/c.html\")\n",
|
||||
"# crawler.parse_xh_news_detail(\"https://www.news.cn/politics/leaders/20240207/2819fe60663140eab9599581dcae8c1e/c.html\") #视频\n",
|
||||
"crawler.parse_xh_news_detail(\"https://www.news.cn/photo/20250523/9fc5e377b19047918dfe0eca2aad5c67/c.html\") # 分页"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"id": "fa359d5b",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# crawler.commend()"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user