我是新來的Python,我試圖從網站獲得ALT和圖片來源,但我現在面臨的問題與報價'
和"
Python的正則表達式查找圖像源
import requests,urllib,urllib2,re
rule = re.compile(r'^[^*$<,>?!\']*$')
r = requests.get('http://www.hotstar.com/channels/star-plus')
match = re.compile('<img alt="(.*?)" ng-mouseleave="mouseLeaveCard()" ng-mouseenter="mouseEnterCard()" ng-click="mouseEnterCard(true)" ng-class="{\'dull-img\': isThumbnailTitleVisible || isRegionalLanguageVisible}" class="show-card imgtag card-minheight-hc ng-scope ng-isolate-scope" placeholder-img="{\'realUrl\' : \'(.*?)\', \'placeholderUrl\' : \'./img/placeholder/hs.jpg\'}" ng-if="record.urlPictures" src="(.*?)" style="display: block;">',re.DOTALL).findall(r.content)
for name,img,image in match:
我只能使用標準的Python庫。
我讀過有關定義規則,所以我從這個做:Regex Apostrophe how to match?
老實說,我不知道如何使用它。
在此先感謝
你的輸入是什麼,你的預期輸出是什麼? – Jokab