Python Forum
Trying to Tabulate Information from an Aircraft Website Link(s)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trying to Tabulate Information from an Aircraft Website Link(s)
#20
Hi i have been busy lately and do have much time for answers.
Can take a little now.
(Jun-18-2019, 01:14 PM)eddywinch82 Wrote: But I get the following Traceback Error :-
Have to be careful with () [] count when have so long line.
Southport = df[(df['Location'].str.contains('- Display')) & (df['Lancaster'].str.contains('L')) | (df['Dakota'] == 'D') & (df['Spitfire'] == 'S') & (df['Hurricane'] == 'H')] 
Southport
I did tow in a |(mean or) to get some matches.
&(means and)

Quote:There are 7 months i.e. March to September, and the Url differs only by the following ending, i.e. march07.html april07.html may07.html etc.
Make months.
>>> import calendar
>>> 
>>> months = filter(None, calendar.month_name)
>>> months = list(months) 
>>> months
['January',
 'February',
 'March',
 'April',
 'May',
 'June',
 'July',
 'August',
 'September',
 'October',
 'November',
 'December']

>>> months[2:5]
['March', 'April', 'May'
Use in url.
import pandas as pd
import requests
from bs4 import BeautifulSoup
import calendar

months = filter(None, calendar.month_name)
months = list(months)

new_table = []
for month in months[2:5]:
    res = requests.get(f"http://web.archive.org/web/20070701133815/http://www.bbmf.co.uk/{month}07.html")
    soup = BeautifulSoup(res.content,'lxml')
    table = soup.find_all('table')[0]
    new_table.append(soup.find_all('table')[0])

print(new_table)
In Pandas eg May month.
import pandas as pd
import requests
from bs4 import BeautifulSoup
import calendar

months = filter(None, calendar.month_name)
months = list(months)

new_table = []
for month in months[2:5]:
    res = requests.get(f"http://web.archive.org/web/20070701133815/http://www.bbmf.co.uk/{month}07.html")
    soup = BeautifulSoup(res.content,'lxml')
    table = soup.find_all('table')[0]
    new_table.append(soup.find_all('table')[0])

df = pd.read_html(str(new_table[2]))

Quote:How can I adapt that Code, so requests will go through all links, to produce the necessary Data, i.e. display all SHD Bookings only, for the Whole year ?
Same way as i showed you over with that other url,and as this is a new task you should try on or own or make a new Thread.
These task(not the easiest) you will get stuck a lot,when have missing basic Python knowledge Wink
Reply


Messages In This Thread
RE: Trying to Tabulate Information from an Aircraft Website Link(s) - by snippsat - Jun-19-2019, 06:07 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to insert Dashed Lines in between Rows of a tabulate output Mudassir1987 0 616 Sep-27-2023, 10:09 AM
Last Post: Mudassir1987
  pandas, tabulate, and alignment menator01 3 7,730 Feb-05-2022, 07:04 AM
Last Post: menator01
  display the result of Dataframe in tabulate format alex80 0 1,472 Sep-09-2020, 02:22 PM
Last Post: alex80
  How to tabulate correctly repeated blocks? Xiesxes 4 3,120 Mar-21-2020, 04:57 PM
Last Post: Xiesxes
  Obtain Geometric Information and name from a map-design website fyec 2 2,562 Aug-08-2018, 05:11 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020