0
yahoo finance에서 간결한 가격의 가격을 얻고 싶습니다. 이 코드를 사용하고 있습니다 :^NSEI의 주가를 얻는 방법
import urllib
import re
url= 'https://in.finance.yahoo.com/q?s=^nsei'
htmlfile=urllib.urlopen(url)
htmltext =htmlfile.read()
regex ='<span id="yfs_l10_^nsei">(.+?)</span>'
pattern = re.compile(regex)
price =re.findall(pattern,htmltext)
print price
출력은 빈 목록입니다. 내 코드에 어떤 문제가 있습니까?
'quote'가 아닌 – cat
이 수정되었습니다. Downvote 완 불필요하지만. –
이렇게하는 또 다른 방법은 원시 문자열을 사용하는 것입니다. 그래서 간단히'r ' (. +?)''모두 당신이 필요합니다. – smac89