国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

腳本之家,腳本語(yǔ)言編程技術(shù)及教程分享平臺(tái)!
分類導(dǎo)航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服務(wù)器之家 - 腳本之家 - Python - python使用BeautifulSoup分析網(wǎng)頁(yè)信息的方法

python使用BeautifulSoup分析網(wǎng)頁(yè)信息的方法

2020-05-29 11:37令狐不聰 Python

這篇文章主要介紹了python使用BeautifulSoup分析網(wǎng)頁(yè)信息的方法,涉及Python使用BeautifulSoup模塊分析網(wǎng)頁(yè)信息的技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了python使用BeautifulSoup分析網(wǎng)頁(yè)信息的方法。分享給大家供大家參考。具體如下:

這段python代碼查找網(wǎng)頁(yè)上的所有鏈接,分析所有的span標(biāo)簽,并查找class包含titletext的span的內(nèi)容

復(fù)制代碼 代碼如下:

#import the library used to query a website
import urllib2

 

#specify the url you want to query
url = "http://www.python.org"

#Query the website and return the html to the variable 'page'
page = urllib2.urlopen(url)

#import the Beautiful soup functions to parse the data returned from the website
from BeautifulSoup import BeautifulSoup

#Parse the html in the 'page' variable, and store it in Beautiful Soup format
soup = BeautifulSoup(page)

#to print the soup.head is the head tag and soup.head.title is the title tag
print soup.head
print soup.head.title

#to print the length of the page, use the len function
print len(page)

#create a new variable to store the data you want to find.
tags = soup.findAll('a')

#to print all the links
print tags

#to get all titles and print the contents of each title
titles = soup.findAll('span', attrs = { 'class' : 'titletext' })
for title in allTitles:
print title.contents

 

希望本文所述對(duì)大家的Python程序設(shè)計(jì)有所幫助。

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 久久精品亚洲一区二区 | 一区国产精品 | 特级毛片在线大全免费播放 | 成人在线免费看视频 | 精品96久久久久久中文字幕无 | 看特级毛片 | 91av视频在线 | www午夜 | 黄片毛片在线观看 | 日韩视频―中文字幕 | 日本精品久久 | 在线观看中文字幕亚洲 | 天天天操操操 | 欧美久久综合 | 91麻豆精品国产91久久久资源速度 | 亚洲视频欧美视频 | 欧美一区二区三区在线播放 | 成人av在线网站 | 黄色国产免费看 | 久久精品一区二区国产 | 久久精品久久久久久 | 久久99这里只有精品 | 亚洲天堂2020 | 精品国产精品三级精品av网址 | 美女视频一区 | 中文字幕不卡 | 欧美日韩在线一区 | 久久精品成人一区二区三区蜜臀 | 亚洲精品一区二区三区蜜桃久 | 成人免费视频在线观看 | 国产成人一区 | 精品日韩一区二区三区 | 亚洲国产成人av好男人在线观看 | 欧美国产精品一区二区三区 | 91嫩草视频在线观看 | 成年人免费在线看网站 | 午夜成人免费视频 | 手机在线观看av | 男人天堂v | 久久影院免费观看 | 在线一二三区 |