如何获取今日头条中的所有页面的网页代码,然后读取文章标题、阅读数、评论数、发布时间到对应的表格中保存
下面是获取网页源代码文件:
Dim web As new windows.forms.webbrowser
web.Navigate("http://toutiao.com/m6051259851/") 我单位在今日头条号的页面
Do Until web.ReadyState = 4
Application.DoEvents
Loop
Dim getReader = new System.IO.StreamReader(web.DocumentStream, Encoding.Default)
Dim str = getReader.ReadToEnd()
output.show(str)
下面是执行上述代码后得到网页源代码文件中的几段关键部分:
<DIV class=pin-content group_id="6275912267754275074" data-type="context">
<TABLE width=680>
<TBODY>
<TR>
<TD height=35>
<H3><A onclick=action_log(this)
href="http://toutiao.com/item/6275915046082052609/" target=_blank 文章在今日头条中的地址
ga_label="index_feed"
ga_event="source_url">全州检察政治工作暨检察官文联筹备会在瓮安召开</A></H3></TD></TR> 文章标题
<TR>
<TD>
<DIV class=list_image>
<UL>
<LI class="img_bg shadow_img"><A onclick=action_log(this)
href="http://toutiao.com/item/6275915046082052609/" target=_blank 文章在今日头条中的地址
ga_label="index_feed" ga_event="source_url"><IMG
onerror=errorimg.call(this)
src="http://p2.pstatp.com/list/5680000b06831514612"></A> </LI>
<LI class="img_bg shadow_img"><A onclick=action_log(this)
href="http://toutiao.com/item/6275915046082052609/" target=_blank
ga_label="index_feed" ga_event="source_url"><IMG
onerror=errorimg.call(this)
src="http://p2.pstatp.com/list/5690008f7f4463406b1"></A> </LI>
<LI class="img_bg shadow_img"><A onclick=action_log(this)
href="http://toutiao.com/item/6275915046082052609/" target=_blank
ga_label="index_feed" ga_event="source_url"><IMG
onerror=errorimg.call(this)
src="http://p2.pstatp.com/list/56a0008d02e19a3e7a5"></A> </LI></UL></DIV> 文章中的插图
<DIV
class=text>4月20日,全州检察政治工作暨检察官文联筹备会在瓮安县检察院召开。州检察院党组成员、副检察长潘凤敏,州院党组成员、政治部主任刘雪红,《法治生活报》专题部主任罗翔,州院政治部全体成员,各县、市检察院分管领导和政工同志参加会议。会议由州院政治部宣传科科长黄永荣主持。</DIV>
<DIV class=clearfix></DIV></TD></TR>
<TR>
<TD>
<TABLE class=item_info width="100%">
<TBODY>
<TR>
<TD>阅读: 516</TD> 文章的阅读数、评论数、发布时间
<TD>评论: 0</TD>
<TD align=right>2016-04-21 15:47
</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV></DIV></DIV>
经过观察,今日头条会每页显示20条信息,多余的按页显示
下面是按页代码
<DIV id=pagebar class=pagebar><A class="pagebar_step pagebar_step_current "
href="http://toutiao.com/m6051259851/">1</A> <A class="pagebar_step "
href="http://toutiao.com/m6051259851/p2/">2</A> <A class="pagebar_step "
href="http://toutiao.com/m6051259851/p3/">3</A> <A class="pagebar_step "
href="http://toutiao.com/m6051259851/p4/">4</A> <A class="pagebar_step "
href="http://toutiao.com/m6051259851/p5/">5</A> <A class="pagebar_step "
href="http://toutiao.com/m6051259851/p6/">6</A> <A
class="pagebar_turn pagebar_turn_next"
href="http://toutiao.com/m6051259851/p2/">下一页</A> </DIV></DIV>
如何利用代码来实现,将上述数组中所有的文章信息全部获取呢?