Last active
August 29, 2015 14:01
-
-
Save alexdelorenzo/a27af718b1e8f097969a to your computer and use it in GitHub Desktop.
quick parse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [26]: import requests | |
In [27]: import bs4 | |
In [29]: url = "http://www.yellowpages.com/raleigh-nc/wake-med-hospital" | |
In [30]: response = requests.get(url) | |
In [31]: bs_content = bs4.BeautifulSoup(response.content) | |
In [32]: bs_content.find('span', 'business-phone') | |
Out[32]: | |
<span class="business-phone phone"> | |
(919) 596-3560 | |
</span> | |
In [35]: full_listings = bs_content.find_all('div', 'business-container-inner') | |
In [36]: len(full_listings) | |
Out[36]: 22 | |
In [37]: for listing in full_listings: | |
....: name = listing.find('a', 'url').text.strip() | |
....: number = listing.find('span', 'business-phone').text.strip() | |
....: print(name, ': ', number) | |
....: | |
Wake Med Health & Hospital : (919) 596-3560 | |
WakeMed : (919) 878-7650 | |
Wake Med Home Health : (919) 350-7990 | |
Center Wake Med Health Care : (919) 847-3168 | |
WakeMed Faculty Physicians Ent-Head & Neck Surgery : (919) 350-1630 | |
WakeMed Doctor Choice : (919) 350-8900 | |
WakeMed : (919) 233-2301 | |
WakeMed : (919) 269-4400 | |
Women's Center of Wake County : (919) 829-3711 | |
FastMed Urgent Care in Wake Forest : (919) 562-3155 | |
Med Mart Urgent Care : (919) 772-9214 | |
Wake Veterinary Hospital Inc : (919) 266-9852 | |
Wake Forest Animal Hospital : (919) 867-5804 | |
North Wake Animal Hospital : (919) 556-1121 | |
East Wake Animal Hospital : (919) 375-4180 | |
Eastern Wake Hospital : (919) 269-4352 | |
Western Wake Medical Ctr : (919) 350-2300 | |
Wake Radiology : (919) 232-4700 | |
Wake Interfaith Hospitality Network : (919) 832-6024 | |
Best Western Raleigh North-Downtown : (877) 722-3422 | |
Holiday Inn RALEIGH NORTH - CAPITAL BLVD : (888) 978-3956 | |
Carymed Primary Care : (919) 238-6132 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment