Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Formatting Output after Web Scrape
#1
Hi,

I have web scraped an HTML table using BeautifulSoup and requests, and now trying to create a DataFrame from the results. My current output is:

['Adams, Chris ']
['ALBANESE, MARC ']
['BAILEY, MARIO ']
['DIAZ DE LA PORTILLA, ESQ., MIGUEL ']
['GONZALEZ, JOSE M']
['JOHNSON, ERIN E']
['KESTI, MICHAEL ']
['KESTI, MICHAEL ']
['KRISCHER, ALAN ']

But I want to format it so it looks like this:

[['Adams, Chris '], ['ALBANESE, MARC '], ['BAILEY, MARIO '], ['DIAZ DE LA PORTILLA, ESQ., MIGUEL '], ['GONZALEZ, JOSE M'], ['JOHNSON, ERIN E'], ['KESTI, MICHAEL '], ['KESTI, MICHAEL '], ['KRISCHER, ALAN ']]

So that it can be inserted to a dictionary such as this:

dictionary={'Name':[['Adams, Chris '], ['ALBANESE, MARC '], ['BAILEY, MARIO '], ['DIAZ DE LA PORTILLA, ESQ., MIGUEL '], ['GONZALEZ, JOSE M'], ['JOHNSON, ERIN E'], ['KESTI, MICHAEL '], ['KESTI, MICHAEL '], ['KRISCHER, ALAN ']]}

So far, this is part my code

new_list = []
    names_list = cell[0].string
    li = list(names_list.split("-"))
    #dic={'Name':names_list}
    #print(dic)
    print(li)
    #lit = li.append(cell[0].string)
    #print(names_list)
Thanks for any help. Let me know if my head is in the right place. Let me know the general scheme of how I should go about doing this and if there is a related problem lmk. thnxx so much !
Reply


Messages In This Thread
Formatting Output after Web Scrape - by yoitspython - Jul-30-2019, 07:26 PM
RE: Formatting Output after Web Scrape - by cvsae - Jul-30-2019, 08:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Scrape for html based on url string and output into csv dana 13 5,359 Jan-13-2021, 03:52 PM
Last Post: snippsat
  scrape data 1 go to next page scrape data 2 and so on alkaline3 6 5,090 Mar-13-2020, 07:59 PM
Last Post: alkaline3
  Formatting Output After Web Scraping yoitspython 3 2,852 Aug-01-2019, 01:22 PM
Last Post: snippsat
  Problem formatting output text aj347 5 4,087 Sep-10-2017, 04:54 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

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