R
R
Ruslan Amerkhanov2018-05-11 16:54:30
Python
Ruslan Amerkhanov, 2018-05-11 16:54:30

How to find a list of the same type of links on the site?

Disclaimer: very amateurish question ;-(
There is a site that contains a table, one of the columns of which has links that start the same way. How can I get a list of these links?
Here are my attempts:

import requests
from bs4 import BeautifulSoup

page = requests.get(
    'https://bitinfocharts.com/top-100-richest-bitcoin-addresses.html')

soup = BeautifulSoup(page.text, 'html.parser')
wallets = soup.findAll('a', href="https://bitinfocharts.com/bitcoin/address/[\w]+")

print(wallets)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ruslan Amerkhanov, 2018-05-11
@nice-coding

cut it myself :-D

import requests
from bs4 import BeautifulSoup
import re

page = requests.get(
    'https://bitinfocharts.com/top-100-richest-bitcoin-addresses.html')

soup = BeautifulSoup(page.text, 'html.parser')
pattern = r"https://bitinfocharts.com/bitcoin/address/[\w]+"
wallets = re.findall(pattern, str(soup))

print(wallets)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question