【发布时间】:2018-11-14 12:57:09
【问题描述】:
我正在尝试使用正则表达式从页面中提取特定部分,但它不起作用。
这是我要从页面中提取的部分:
"publishedTimeText":{"runs":[{"text":"1 day ago","navigationEndpoint":{"clickTrackingParams":"CLQBEPS8AiITCPGhkIPt094CFc8SKgodd30BJSibHA==","commandMetadata":{"webCommandMetadata":{"url":"/channel/UCqwUrj10mAEsqezcItqvwEw/community?lb=Ugy4VG4gQFILnreq-Bd4AaABCQ","webPageType":"WEB_PAGE_TYPE_BROWSE"}}
到目前为止,我已经尝试过了:
import requests
import re
r = requests.get('http://rophoto.es/kha.txt')
mystrx = re.search(r'^{"publishedTimeText":.*"WEB_PAGE_TYPE_BROWSE"}}', html_source)
但它对我没有用。
【问题讨论】:
-
尝试删除
^{中的{
标签: python regex python-3.x