网络刮削股票挑战:非类型对象没有属性s

2024-03-29 14:25:02 发布

您现在位置:Python中文网/ 问答频道 /正文

Python初学者和CS新手。你知道吗

对于数组的挑战问题。你知道吗

group with array

尝试了组,但无法使用userinput运行值。 group with userinput

对于带有userinput的数组中的所有公司名称,start、end和run都是平滑的。你知道吗

但是

import re
import urllib.request
url = "#this is counted as link but I don't have more than 10 reputation."

arrayofStocks = ["FB", "GOOG", "DATA", "BABA"]

for i in range(0, 4):
    url = url + arrayofStocks[i]

    data= urllib.request.urlopen(url).read()

    data1=data.decode("utf-8")



m=re.search('meta itemprop="price"',data1)
start=m.start()
end=start+50
newString = data1[start:end]


m=re.search("content=",newString)
start=m.end()
newString1=newString[start:]
m=re.search("/",newString1)
start =0
end=m.end()-3
final=newString1[0:end]
print("The value of " +arrayofStocks[i].upper()+" is "+final)

/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4 /Users/ying2ra/PycharmProjects/stock/Final The value of FB is "127.21 Traceback (most recent call last): File "/Users/ying2ra/PycharmProjects/stock/Final", line 17, in start=m.start() AttributeError: 'NoneType' object has no attribute 'start'

Process finished with exit code 1

自从FB有自己的值以来,我的varm在第一次运行之后发生了什么?你知道吗

API是一个很好的解决方案,但是google关闭了googlefinance的API。你知道吗


Tags: reurlsearchfbiswithgroup数组