Reputation: 1068
I am having such a hard time figuring out why this does not work. The URL is this: https://www.cmlviz.com/pivot-points/GOOG
I want to parse the table with the checkboxes, its class name is "updatable" with an ID of "pivot_data_grid". What am I doing wrong? This is driving me crazy! I just want to get the value of each row in the table along with the title (ex: 5-day Exponential Moving Average). Thank you for any help
string url = "https://www.cmlviz.com/pivot-points/{symbol}".Replace("{symbol}", symbol);
HtmlDocument htmlDoc = new HtmlDocument();
htmlDoc.LoadHtml(url);
//var nodes = htmlDoc.DocumentNode.SelectNodes("//div[@id=pivot_data_grid]/table");
var table = htmlDoc.DocumentNode.SelectNodes("//div[@class='updatable']");
var table = htmlDoc.DocumentNode.SelectSingleNode("//div[@class='updatable']/table");
Upvotes: 0
Views: 61
Reputation: 11525
from bs4 import BeautifulSoup
import requests
r = requests.get(
"https://www.cmlviz.com/inc/pivot-points.php?ticker=GOOG&key=57f42fb7382e7ef5679277fb3c2431c1")
soup = BeautifulSoup(r.text, 'html.parser')
for item in soup.findAll("div", {'class': 'updatable'}):
print(item.get_text("\n", strip=True))
Output:
Alphabet Inc Real-time Moving Average Pivot Points
Current Price
$
1,351.22
-1.27 Fibonacci Extension
$711.74
52 Week Low
$977.66
Select MAs for your chart:
5-day Exponential Moving Average
$
1,351.99
8-day Exponential Moving Average
$
1,349.83
10-day Exponential Moving Average
$
1,347.71
13-day Exponential Moving Average
$
1,344.21
21-day Exponential Moving Average
$
1,334.60
50-day Simple Moving Average
$
1,300.28
200-day Simple Moving Average
$
1,206.62
.382 Fibonacci Retracement
$1,216.62
.50 Fibonacci Retracement
$1,171.00
.618 Fibonacci Retracement
$1,125.37
52 Week High
$1364.33
1.27 Fibonacci Extension
$1,735.43
RSI 20
63.20
Upvotes: 1