Hi,
I am a beginner in Python programming. Of late, I have started learning web scraping after completing python programming course from Udemy. I was trying to scrape this website but unfortunately could not get the csv file. Moreover, total number is also not printing. There maybe more errors. Can you please figure it out and help me with simple explanation. I am just a couple of days old in web scraping.
I am a beginner in Python programming. Of late, I have started learning web scraping after completing python programming course from Udemy. I was trying to scrape this website but unfortunately could not get the csv file. Moreover, total number is also not printing. There maybe more errors. Can you please figure it out and help me with simple explanation. I am just a couple of days old in web scraping.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
from bs4 import BeautifulSoup import requests import pandas as pd api_dict = {} api_no = 0 while True : response = requests.get(url) data = response.text soup = BeautifulSoup(data, 'html.parser' ) apis = soup.find_all( 'td' ,{ 'class' : 'views-field views-field-title col-md-3' }) for api in apis: name = api.find( 'a' ).text api_no + = 1 #print(name) url_tag = soup.find( 'a' ,{ 'title' : 'Go to next page' }) if url_tag.get( 'href' ): #print(url) else : break print ( 'Total APIs: ' ,api_no) api_dict_df = pd.DataFrame.from_dict(api_dict, orient = 'index' , columns = [ 'API name' ]) api_dict_df.head() api_dict_df.to_csv( 'api_detail.csv' ) |