1

This is the code I use to extract data from multiple URLs. Unfortunately, I wasn't able to get it to work for multiple URLs in a list.

Any thoughts?

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()
1
  • So why not try and loop and load each url separately? What made you think that urllib.urlopen() would support a list argument? Commented Mar 14, 2014 at 8:25

1 Answer 1

3

try this

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()

You have to use loop for each url.

Sign up to request clarification or add additional context in comments.

1 Comment

It didn't work. It only printing out the 1st URL. Not all the URLs in the list.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.