Python Forum
'For' command and filling excel table with pandas by doing web-scrabbing
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
'For' command and filling excel table with pandas by doing web-scrabbing
#2
Your df has been reinitialized every time in for loop. So just put it in front of for:

df = pd.DataFrame(columns=['code_and_name', 'approximate_elevation'])
for i in range(3):
    driver.get(str(websites['sitelist'][i]))
    code_and_name = driver.find_element_by_id("Span1").text
    approximate_elevation = driver.find_element_by_xpath(
        "//table[@id='Table3']/tbody/tr[3]/td[2]").text
    df.at[i, 'code_and_name'] = str(code_and_name)
    df.at[i, 'approximate_elevation'] = str(approximate_elevation)
Output:

,code_and_name,approximate_elevation
0,D15A200 İNCEĞİZ AYVACA D.,"960,00 m."
1,D15A257 TUTMAÇ BAŞÖREN D.,"1379,00 m."
2,D15A014 ÇEŞME ARKI YEŞİLHİSAR Ç.,"1131,00 m."
Reply


Messages In This Thread
RE: 'For' command and filling excel table with pandas by doing web-scrabbing - by shinemic - Jul-28-2018, 10:57 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  page navigation & form filling rudolphyaber 0 1,689 Mar-13-2019, 06:31 PM
Last Post: rudolphyaber

Forum Jump:

User Panel Messages

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