Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7从json api中从多个URL提取数据_Python_Json - Fatal编程技术网

Python 2.7从json api中从多个URL提取数据

Python 2.7从json api中从多个URL提取数据,python,json,Python,Json,这是我用来从多个URL提取数据的代码。 不幸的是,我无法让它在列表中的多个URL上工作 有什么想法吗 import urllib import re urls = ("http://pool.webcoin.us/plt/index.php/?page=api&action=getpoolstatus&api_key=0c57173da8c900831fc111003ea636d5c261e79e76b670f3b51a2d325f9b94db", "http:

这是我用来从多个URL提取数据的代码。 不幸的是,我无法让它在列表中的多个URL上工作

有什么想法吗

import urllib
import re

urls = ("http://pool.webcoin.us/plt/index.php/?page=api&action=getpoolstatus&api_key=0c57173da8c900831fc111003ea636d5c261e79e76b670f3b51a2d325f9b94db",
        "http://uno.coin-pool.org/index.php?page=api&action=getpoolstatus&api_key=f20daa5ea5945c1b9641b81d8dd9f4b556153182c03a2a2a94d7a95abc6dc4f8",
        "http://goat.easy-mining.net/index.php?page=api&action=getpoolstatus&api_key=5d232e86cd1a0cdfdafdcb0722da48c21778d35cd8654f7dbc82202881163df9")

for url in urls:

    source = urllib.urlopen(url)
    regexp = r">(\d+(?:\.\d*)?)<"
    found = 0


    for line in source.readlines():
        if found:
            match = re.search(regexp,line)
            break
        if "networkdiff" in line:
            found = 1



    print match.groups()
导入urllib
进口稀土
URL=(“http://pool.webcoin.us/plt/index.php/?page=api&action=getpoolstatus&api_key=0c57173da8c900831fc111003ea636d5c261e79e76b670f3b51a2d325f9b94db",
"http://uno.coin-pool.org/index.php?page=api&action=getpoolstatus&api_key=f20daa5ea5945c1b9641b81d8dd9f4b556153182c03a2a2a94d7a95abc6dc4f8",
"http://goat.easy-mining.net/index.php?page=api&action=getpoolstatus&api_key=5d232e86cd1a0cdfdafdcb0722da48c21778d35cd8654f7dbc82202881163df9")
对于url中的url:
source=urllib.urlopen(url)
regexp=r“>(\d+(?:\。\d*)?)试试这个

import urllib
import re

urls = ["http://ffc.coinz.pw/index.php?page=statistics&action=pool",
       "http://pool.webcoin.us/plt/index.php/?page=api&action=getpoolstatus&api_key=0c57173da8c900831fc111003ea636d5c261e79e76b670f3b51a2d325f9b94db",
       "http://uno.coin-pool.org/index.php?page=api&action=getpoolstatus&api_key=f20daa5ea5945c1b9641b81d8dd9f4b556153182c03a2a2a94d7a95abc6dc4f8",
       "http://goat.easy-mining.net/index.php?page=api&action=getpoolstatus&api_key=5d232e86cd1a0cdfdafdcb0722da48c21778d35cd8654f7dbc82202881163df9"]

for url in urls:
    source = urllib.urlopen(url)
    regexp = r">(\d+(?:\.\d*)?)<"
    found = 0

    for line in source.readlines():
        if found:
            match = re.search(regexp,line)
            break
        if "Current Difficulty" in line:
            found = 1

        for link in url(x):
            x += 1



    print match.groups()
导入urllib
进口稀土
URL=[”http://ffc.coinz.pw/index.php?page=statistics&action=pool",
"http://pool.webcoin.us/plt/index.php/?page=api&action=getpoolstatus&api_key=0c57173da8c900831fc111003ea636d5c261e79e76b670f3b51a2d325f9b94db",
"http://uno.coin-pool.org/index.php?page=api&action=getpoolstatus&api_key=f20daa5ea5945c1b9641b81d8dd9f4b556153182c03a2a2a94d7a95abc6dc4f8",
"http://goat.easy-mining.net/index.php?page=api&action=getpoolstatus&api_key=5d232e86cd1a0cdfdafdcb0722da48c21778d35cd8654f7dbc82202881163df9"]
对于url中的url:
source=urllib.urlopen(url)

regexp=r“>(\d+(?:\。\d*))那么为什么不尝试分别循环和加载每个url呢?是什么让您认为
urllib.urlopen()
会支持列表参数?它不起作用。它只打印出第一个URL。不是列表中的所有URL。