Im working on a program that automatically downloads charts from the FAA website.
here's the table im trying to scrape off of
the link to the actual website: https://www.faa.gov/air_traffic/flight_info/aeronav/digital_products/dtpp/search/results/?cycle=2014&ident=kiah
here's a block of python code:
try:
links = driver.find_elements_by_xpath("//table[@id = 'resultsTable']//tbody/tr/td/a")
names = []
dlinks = []
for element in links:
names.append(element.text)
dlinks.append(element.get_attribute("href"))
for printNames in names:
print("Name-" + printNames)
for printDlinks in dlinks:
print("Link-" + printDlinks)
break
But whenever I run the program dlinks.append(element.get_attribute("href"))
seems to only append the first link in the html table for every iteration while the element.text does what it's supposed to do.
a piece of the output:
Name-TAKEOFF MINIMUMS
Link-http://aeronav.faa.gov/d-tpp/2014/sc5to.pdf#nameddest=(IAH)
Name-ALTERNATE MINIMUMS
Link-http://aeronav.faa.gov/d-tpp/2014/sc5to.pdf#nameddest=(IAH)
Name-LAHSO
Link-http://aeronav.faa.gov/d-tpp/2014/sc5to.pdf#nameddest=(IAH)
Name-DOOBI TWO (RNAV)
Link-http://aeronav.faa.gov/d-tpp/2014/sc5to.pdf#nameddest=(IAH)
same exact link for all of them
Whenever I replace dlinks.append(element.get_attribute("href"))
with print(element.get_attribute("href"))
in the for loop it works perfectly fine at iterating over all the links but theres only a problem whenever try to append the result to a list.
result when made the change above:
http://aeronav.faa.gov/d-tpp/2014/sc5to.pdf#nameddest=(IAH)
http://aeronav.faa.gov/d-tpp/2014/sc5alt.pdf#nameddest=(IAH)
http://aeronav.faa.gov/d-tpp/2014/sc5lahso.pdf#nameddest=(IAH)
it printed but didn't append
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…