1
我使用beautifulsoup来抓取网站中的不同数据。 我试图抓取源,但不是所有的来源,只是对我很重要的子字符串。在html图像src中查找子字符串的正则表达式
例如,在这个项目中,我想选择/和.png(在本例中是“nyt”)之间的字符串并将其保存在列表中。
<image width="185" height="26"
xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:href="https://a1.nyt.com/assets/shell/20160613-034030/images/foundation/logos/nyt-logo-185x26.svg" src="https://a1.nyt.com/assets/shell/20160613-034030/images/foundation/logos/nyt.png" border="0"></image>
我一直在试图与像re.search几个正则表达式( '[A-Z] *。PNG',SRC)。集团(0),但没有什么效果很好。
谁能告诉我什么是正确的方式来刮这些信息?
你能告诉我们你要提取该字符串的确切部分? – zython