Midnightsun Posted January 13, 2022 Report Posted January 13, 2022 https://www.epa.gov/greenpower/green-power-partnership-national-top-100 I need to extract table from the website using python pandas and beautiful soup import pandas as pd .. code:: ipython2 from bs4 import BeautifulSoup import requests .. code:: ipython2 url = "https://www.epa.gov/greenpower/green-power-partnership-national-top-100 " .. code:: ipython2 page = requests.get(url) .. code:: ipython2 Soup = BeautifulSoup(page.content,'html.parser') .. code:: ipython2 table = Soup.find('div', attrs = {'id':'top'}) for row in table.findAll('div', attrs = {'class':'path-node not-front node-page node-page--node-type-page'}): :: File "<ipython-input-23-68516b8d7040>", line 4 attrs = {'class':'path-node not-front node-page node-page--node-type-page'}): ^ IndentationError: expected an indented block .. code:: ipython2 filename = 'greenpower.csv' with open(filename, 'w') as f: w = csv.DictWriter(f) w.writeheader() w.writerow(top) Quote
Midnightsun Posted January 13, 2022 Author Report Posted January 13, 2022 Just now, fake_Bezawada said: google cheyyi bro tension nahi leneka...oka freelancer ni hire chesanu....vadu inka chuskoledu file ikkada evarikina telusthe it helps Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.