用Python 正則表達(dá)式識別樓主的實(shí)際操作步驟介紹
你知道如何用Python 正則表達(dá)式來識別樓主嗎?如果你想知道用Python 正則表達(dá)式來識別樓主的實(shí)際應(yīng)用方案的具體操作的話,你就可以點(diǎn)擊以下的文章對其進(jìn)行了解,望你會有所收獲。
識別樓主:
帖子代碼片段:<!-- 天涯百寶箱 -->
- <script>
- var chrType = "public";
- var intAuthorId = "";
- var chrAuthorName = "GreyHouse";
- var chrTitle = "[光影記錄]跳蚤的歐洲之行";
- var chrItem = 'travel';
- var intItem = '0';
- var intArticleId = "191157";
- var tAuthor = 'GreyHouse';
- </script>
使用以下的Python 正則表達(dá)式來找到樓主:
- rereg_louzhu = re.compile('.*chrAuthorName = "(.*?)"; '
設(shè)mat為reg_louzhu.match(網(wǎng)頁源碼html行);則mat.groups()[0] 為樓主名字 GreyHouse
識別一個(gè)帖子的起始位置
繼續(xù)分析html,發(fā)現(xiàn)天涯回帖一般都是用作者信息欄作為帖子的起始,那么帖子的尾部就是下一個(gè)作者信息欄之前咯。
<TABLE cellspacing=0 border=0 bgcolor=f5f9fa
width=100% ><TR><TD WIDTH=100 ALIGN=RIGHT
VALIGN=bottom></TD><TD><font size=-1
color=green><br><center>作者:<a
href="/browse/Listwriter.asp?vid=11288815&vwriter=
開著坦克逛街&idwriter=0&key=0" target=_blank>開著坦克逛街</a>
以上內(nèi)容就是對Python 正則表達(dá)式與識別一個(gè)帖子的起始位置的部分介紹
【編輯推薦】
- 在Python Library中Event具體實(shí)際操作方案
- Python socket編程在具體應(yīng)用中前兩個(gè)步驟的介紹
- Python矩陣轉(zhuǎn)置中的二維數(shù)組的實(shí)際操作方案介紹
- Python環(huán)境的實(shí)際應(yīng)用方案介紹與代碼詳解
- 在PythonS60手機(jī)運(yùn)行過程中的五大步驟