无论如何要抓取特定信息

Is there anyway to scrape specific information

如何获取位于 Base Url 中的 'star_recom' 信息?

Star_recom 的类型是数字(例如 49%),正如您在 BaseUrl 中看到的那样。

请检查代码并告诉我是否有任何问题。

BaseUrl = 'https://www.jobplanet.co.kr/companies/90364/'
req = requests.get(BaseUrl)
soup = BeautifulSoup(req.text,'html.parser')
body = soup.find("div",{"class":"body_wrap"})
sbody= body.find("dl", {"class":"rate_bar_set"})


star_recom = body.find('div', class_='pie1').find('span', class_='txt_point').text.strip() 

你的代码是正确的,但它不会 return 任何东西,因为你试图抓取的数据是由正文中的 JavaScript 函数写入的。

<div class="review_stats-pagination"></div>
<script>
  ;(function($){
    // Fill animations


    // Dummy data
    var data = [
      {label:'직원의 기업 추천율',val : 0.85},
      {label:'직원이 전망하는 성장 가능성',val : 0.81},
      {label:'이 기업의 CEO 지지율',val : 0.93 }
    ];

你可以试试:

import re
BaseUrl = 'https://www.jobplanet.co.kr/companies/90364/'
req = requests.get(BaseUrl).text

# extract the values as it is in the dom
spans = re.findall( r',val\s*:\s*(.*?)}', req )
print(spans)

输出:

['0.85', '0.81', '0.93 ']

如果您想要完全相同的信息:

# convert it to look like the data displayed on the html
text_as_website = ['{}%'.format(int(float(span) * 100)) for span in spans]
print(text_as_website)

输出:

['85%', '81%', '93%']