新浪微博定位页面代码解析

一个页面包含10条定位微博,可以利用feed_page=number进行翻页爬取。

<div class=\"WB_feed_type SW_fun S_line2 \" mid=\"3571410952070160\"  action-type=\"feed_list_item\">\r\n\t\t\t\t<div class=\"WB_feed_datail S_line2 clearfix\">\r\n\t\t\t<div class=\"WB_face\">代码后开始定位微博信息,前面是周边热门图片信息。

共XXXX条周边微博

以下分别定位字段为,mid,content,locate,geo,date

<div class=\"WB_feed_type SW_fun S_line2 \" mid=\"3571410952070160\"

<\/div>\r\n\t\t\t\t<div class=\"WB_text\" node-type=\"feed_list_content\>+微博内容(例如:这里很堵啊。。。。)

<div class=\"map_data\"><span class=\"W_ico16 icon_locate\"><\/span>+位置信息(例如:浙江省,杭州市,上城区,环城东路 )

 - <a href=\"javascript:void(0);\" action-type=\"feed_list_geo_info\" action-data=\"geo=120.183074,30.243961&head=http:\/\/tp3.sinaimg.cn\/2843497510\/50\/40021333668\/1&title=尤文-觉罗-不满族-浙江省,杭州市,上城区,环城东路\">

<a target=\"_blank\" href=\"\/2843497510\/ztXIX8GxG\" title=\"2013-04-26 19:03\" date=\"1366974184000\"

一条微博结束的标志

<\/div>\r\n\t\t\t<\/div>\r\n\t\t<\/div>\r\n\t<\/div>\r\n\t\t \r\n 

利用相应标志通过正则式提取需要的字段存进数据库,其中mid用于判重。


数据库表的设计

date类型表示YYYY-MM-DD

datetime类型表示YYYY-MM-DD HH:MM:SS

+-----------+----------+------+-----+---------+-------+
| Field     | Type     | Null | Key | Default | Extra |
+-----------+----------+------+-----+---------+-------+
| mid       | char(16) | YES  |     | NULL    |       |
| content   | blob     | YES  |     | NULL    |       |
| locate    | char(20) | YES  |     | NULL    |       |
| longitude | char(10) | YES  |     | NULL    |       |
| latitude  | char(10) | YES  |     | NULL    |       |
| date      | datetime | YES  |     | NULL    |       |
+-----------+----------+------+-----+---------+-------+

在实践过程过程中发现存入blob的时候中文出现乱码问题,所以改成用text了

+-----------+----------+------+-----+---------+-------+
| Field     | Type     | Null | Key | Default | Extra |
+-----------+----------+------+-----+---------+-------+
| mid       | char(16) | YES  | UNI | NULL    |       |
| content   | text     | YES  |     | NULL    |       |
| locate    | char(20) | YES  |     | NULL    |       |
| longitude | char(10) | YES  |     | NULL    |       |
| latitude  | char(10) | YES  |     | NULL    |       |
| date      | datetime | YES  |     | NULL    |       |
+-----------+----------+------+-----+---------+-------+
6 rows in set (0.01 sec)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值