无法在Python中检索innerText / innerHTML

时间:2017-07-14 17:36:16

标签: python html

Hovering over innerText shows the text data but not through Python

我正在尝试从此网站的HTML中检索innertext或innerHTML(参见附图)。从BeautifulSoup保存/打印的HTML没有在innerText的附加图像中看到的内容。

import requests, re
from bs4 import BeautifulSoup

r=requests.get("https://jobs.ca.gov/CalHRPublic/Search/JobSearchResults.aspx#classid=441")
c=r.content

soup=BeautifulSoup(c,"html.parser")
print (soup.prettify())

当我在Google Chrome浏览器中检查页面时,点击div块并复制HTML,Chrome检测到的复制HTML包含我要查找的所有数据。

如何在Python中获取相同的数据,还是必须使用Selenium?

<div class="card-block" id="collapse1234" itemscope="" itemtype="http://schema.org/Organization" role="tablist" aria-multiselectable="true">
                                    <div class="row" role="presentation">
                                        <div class="col-md-10 " role="presentation">
                                            <a id="cphMainContent_rptResults_hlViewJobPosting_0" class="lead visitedLink" href="/CalHrPublic/Jobs/JobPosting.aspx?JobControlId=70488">ACCOUNTING ADMINISTRATOR I (SPECIALIST)</a>

                                        </div>


                                            <div class="col-md-2 tar">
                                                <div id="cphMainContent_rptResults_pnlFavoriteJob_0" class="aspNetDisabled" style="display: inline;">

                                                    <i id="cphMainContent_rptResults_iIsNotFavorite_0" class="fa fa-star-o" aria-hidden="true" style="cursor:default;color:grey;opacity:.6;" title="You must be logged in to save a job as a Favorite." onclick="">
                                                        Log in to save job
                                                    </i>
                                                    <i id="cphMainContent_rptResults_iIsFavorite_0" class="fa fa-star" title="This job is saved" style="color:#fdb81e;cursor:pointer;display:none;" aria-hidden="true" onclick="removeUserFavorite(70488, $(this) );">&nbsp;Job saved</i>

</div>
                                            </div>


                                    </div>
                                    <div class="row" role="presentation">
                                        <div class="col-sm-12 col-md-9" role="presentation">
                                            <div class="row">
                                                <div class="col-xs-12 col-sm-6" role="presentation">
                                                    <div class="working-title details row">
                                                        <div class="col-xs-6 job-label">Working Title:</div>
                                                        <div class="col-xs-6 job-details">
                                                            <span title="Keyword Relevance: 0">N/A</span>

                                                        </div>
                                                    </div>
                                                    <div class="position-number details row">
                                                        <div class="col-xs-6 job-label">Job Control:</div>
                                                        <div class="col-xs-6 job-details">
                                                            70488
                                                        </div>
                                                    </div>
                                                    <div class="salary-range details row">
                                                        <div class="col-xs-6 job-label">Salary Range:</div>
                                                        <div class="col-xs-6 job-details">
                                                            $5053.00 - $6325.00
                                                        </div>
                                                    </div>
                                                    <div class="schedule details row">
                                                        <div class="col-xs-6 job-label">Work Type/Schedule:</div>
                                                        <div class="col-xs-6 job-details">
                                                            Permanent Fulltime
                                                        </div>
                                                    </div>

                                                </div>
                                                <div class="col-xs-12 col-sm-6" role="presentation">
                                                    <div class="department details row">
                                                        <div class="col-xs-6 job-label">Department:</div>
                                                        <div class="col-xs-6 job-details">
                                                            Board of Equalization
                                                        </div>
                                                    </div>
                                                    <div class="location details row">
                                                        <div class="col-xs-6 job-label">Location:</div>
                                                        <div class="col-xs-6 job-details">
                                                            Sacramento County
                                                        </div>
                                                    </div>
                                                    <div class="filing-date details row">
                                                        <div class="col-xs-6 job-label">Publish Date:</div>
                                                        <div class="col-xs-6 job-details">
                                                            <time datetime="2016-06-30">
                                                                6/29/2017</time>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-sm-12 col-md-3 align-right" role="presentation">
                                            <div class="filing-date details row">
                                                <div class="col-xs-12">
                                                    <div class="job-label">Filing Deadline:</div>
                                                    <div class="job-details">
                                                        <time datetime="2016-06-30">
                                                            7/14/2017
                                                        </time>
                                                    </div>
                                                </div>
                                                <div class="col-xs-12">
                                                    <a id="cphMainContent_rptResults_hlViewPosting_0" class="btn btn-secondary btn-block" href="/CalHrPublic/Jobs/JobPosting.aspx?JobControlId=70488">
                                                <span class="ca-gov-icon-search"></span>
                                                    <span>View Job Posting</span>
                                                    </a>
                                                </div>                                                   
                                            </div>
                                        </div>                                        

                                    </div>
                                </div>

0 个答案:

没有答案