Created
September 3, 2016 03:12
-
-
Save enginebai/f844a1ff851c1df8a921e97a4d1f692e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def parse_shop_information(shop_link): | |
shop_id = re.sub(re.compile(r'^.*/' + SHOP_PATH), '', shop_link).split('-')[0] | |
print(shop_id) | |
req = requests.get(shop_link) | |
if req.status_code == requests.codes.ok: | |
soup = BeautifulSoup(req.content, HTML_PARSER) | |
shop_header_tag = soup.find('div', id='shop-header') | |
name_tag = shop_header_tag.find('span', attrs={'itemprop': 'name'}) | |
print(re.sub(SPACE_RE, '', name_tag.text)) | |
category_tag = shop_header_tag.find("p", class_={'cate i'}) | |
print(re.sub(SPACE_RE, '', category_tag.a.text)) | |
address_tag = shop_header_tag.find('a', attrs={'data-label': '上方地址'}) | |
print(re.sub(SPACE_RE, '', address_tag.text)) | |
gps_str = address_tag['href'] | |
print(gps_str) | |
gps_str = re.search('/c=(\d+.\d*),(\d+.\d*)/', gps_str).group().replace('/', '') | |
print(gps_str) | |
lat = gps_str.split(',')[0] | |
lng = gps_str.split(',')[1] | |
print(lat.split('=')[1], lng) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment