直接上代码:
复制代码 代码如下:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import urllib
import os,datetime,string
import sys
from bs4 import BeautifulSoup
reload(sys)
sys.setdefaultencoding('utf-8')
__BASEURL__ = 'http://bj.58.com/'
__INITURL__ = "http://bj.58.com/shoujiweixiu/"
soup = BeautifulSoup(urllib.urlopen(__INITURL__))
lvlELements = soup.html.body.find('div','selectbarTable').find('tr').find_next_sibling('tr')('a',href=True)
f = open('data1.txt','a')
for element in lvlELements[1:]:
f.write((element.get_text()+'\n\r' ))
url = __BASEURL__ + element.get('href')
print url
soup = BeautifulSoup(urllib.urlopen(url))
lv2ELements = soup.html.body.find('table','tblist').find_all('tr')
for item in lv2ELements:
addr = item.find('td','t').find('a').get_text()
phone = item.find('td','tdl').find('b','tele').get_text()
f.write('地址:'+addr +' 电话:'+ phone + '\r\n\r')
f.close()
直接执行后,存在 data1.txt中就会有商家的地址和电话等信息。
BeautifulSoup api 的地址为: http://www.crummy.com/software/BeautifulSoup/bs4/doc/
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。