在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Python/ python 利用beautifulSoup提取頁面多個標簽的文本內容

python 利用beautifulSoup提取頁面多個標簽的文本內容

初學beautifulsoup解析庫,拿一個招聘網頁練手,想達到提取多個標簽的文本內容,但是目前只可以提取到單個標簽的單個文本內容,多標簽的文本如何提???

from requests.exceptions import RequestException
import requests
from bs4 import BeautifulSoup


def get_one_page(url):
    try:
        response = requests.get(url)
        if response.status_code == 200:
            return response.text
        return None
    except RequestException:
        return None

def parse_one_page(html):
    soup = BeautifulSoup(html,'lxml')
    html = soup.find_all(class_='infolist-row')
    for a in html:
        print(a.find_all('a')[0])

def main():
    url = 'https://www.0951job.com/jobs/jobs-list.php'
    html = get_one_page(url)
    parse_one_page(html)

if __name__ == '__main__':
    main()

頁面url:https://www.0951job.com/jobs/...
class_='infolist-row'是提取內容的主節(jié)點,其余元素是副節(jié)點
所以請教大佬,如何提取副節(jié)點文本內容并且遍歷以列表形式。是多次解析?
請大佬指點一下,謝謝

回答
編輯回答
青黛色

比如你要a.find_all('a')0鏈接url成列表的話

l = [a.find_all('a')[0]['href'] for a in html] #這樣l就是一個url的列表
2017年11月28日 01:26