Jan-23-2020, 09:37 AM
hi Guys,
I have been working on a script that does parsing to a website (thanks to snippsat).
I am trying to import the data that is recieved to excel. I know pandas is a strong tool but have no clue how to use it :)
the code that does the parsing is:
thanks
I have been working on a script that does parsing to a website (thanks to snippsat).
I am trying to import the data that is recieved to excel. I know pandas is a strong tool but have no clue how to use it :)
the code that does the parsing is:
from requests import Session from bs4 import BeautifulSoup as bs with Session() as s: site = s.get("https://connectedinvestors.com/login") bs_content = bs(site.content, "html.parser") token = bs_content.find("input", {"name":"infusion_id"})["value"] login_data = {"email":"[email protected]","password":"password", "infusion_id":token} s.post("https://connectedinvestors.com/login",login_data) import requests from bs4 import BeautifulSoup url = 'https://connectedinvestors.com/member/jonathan-kessous/friends/2' url_get = requests.get(url) soup = BeautifulSoup(url_get.content, 'html.parser') for tag in soup.find_all('div', class_="investorcard clearfix"): h4 = tag.find('h4') print(h4.a.text.strip(), tag.attrs['id'])the output of the code is like this:
Output:... print(h4.a.text.strip(), tag.attrs['id'])
...
Jonathan Kessous 454517
Dorothy Lopez 5374
Malachi Minenger 503265
Carla Moore 492866
Marty Gergen 404449
Daniel Nevins 326033
Mike Abadir 406439
Meeco White 342115
Craig Dell 505777
Keiara Smith 409082
Rebecca Jones 527554
jeff black 358077
Steven Stoughton 488587
Brian Newell 539314
Curtis Dafler 410079
Marco Leone 19002
Oscar Robertson 522916
Nilson Almonte Noesi 472794
Nikia Epiconepropertiesllc 508013
Andrew Tuggle 342415
R. Gibsonproperties 542422
Dominic Picione 543130
Yaron Kendelker 253869
Charles Jones 539585
Eric Brewer 543986
Ginis Garcia 7206
Richard Williams 466632
Lloyd Pierson 538263
Matthew Lorimer 372537
Nate Hedrick 501890
Steven Jackson 521127
>>>
what i need is that the output will be imported to an excel file with two columns (Name and ID).thanks