0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Python BeautifulSoup aタグ取得について

Posted at

あるサイトのURLを取得試みたが、出来なかった

<a href="/company/cmi0179173001/nx1_rq0023287251/?fr=cp_s00700&amp;list_disp_no=1&amp;leadtc=n_ichiran_cst_n5_ttl" target="_blank" class="rnn-linkText rnn-linkText--black">CADオペ/設計補助エンジニア◆未経験歓迎◆年休122日</a>

スクリーンショット 2022-11-27 14.58.54.png
欲しいURLは下記だが、

/company/cmi0179173001/nx1_rq0023287251/?fr=cp_s00700&amp
boxs = soup.find_all('ul', attrs={'class': 'rnn-group rnn-group--xm rnn-jobOfferList'})
    for box in boxs:
        links = box.find_all('a', attrs={'class': 'rnn-linkText rnn-linkText--black'})
        for link in links:
            link = link.text

textを実施すると、「CADオペ/設計補助エンジニア◆未経験歓迎◆年休122日」が取得できてしまう
解決策はとても簡単で、textではなくget('href')で解決

boxs = soup.find_all('ul', attrs={'class': 'rnn-group rnn-group--xm rnn-jobOfferList'})
    for box in boxs:
        links = box.find_all('a', attrs={'class': 'rnn-linkText rnn-linkText--black'})
        for link in links:
            link = link.get('href')
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?