Reputation: 45
so here is my code I'm trying to get working
import requests
from bs4 import BeautifulSoup
url = 'https://digitalcoinprice.com'
source_code = requests.get(url)
plain_text = source_code.text
soup = BeautifulSoup(plain_text, "html.parser")
for link in soup.find_all('a', {'class': 'coin_currency_name'}):
title = link.string
print(title)
my ultimate goal is to create a web crawler that will log the information of the top 100 cryptocurrencies every 5 minutes. I'd like to work this problem out but am struggling with this hurdle. when I run
python wcrawl.py
all it does is moves to where I can type a new command.... Sorry I'm not knowledgeable enough on the topic to give any more detail, I have been using python a whole 12 hours now.
just some more info:
Windows 10 inside Anaconda CMD Prompt Python 3.7.2
Upvotes: 1
Views: 84
Reputation: 333
You should to find 'span' tag instead 'a' tag.
import requests
from bs4 import BeautifulSoup
url = 'https://digitalcoinprice.com'
source_code = requests.get(url)
plain_text = source_code.text
soup = BeautifulSoup(plain_text, "html.parser")
for link in soup.find_all('span', {'class': 'coin_currency_name'}):
title = link.string
print(title)
Upvotes: 1
Reputation: 84465
You can use pandas and read_html for this
import pandas as pd
tables = pd.read_html('https://digitalcoinprice.com/')
print(tables[0])
If doing a lot consider also using an API method
Upvotes: 0