このプロジェクトでは、「ウェブサイト」をスクラップする必要があります。これは、ローカルフォルダのhtmlファイルです。とにかく、私は各学生のオブジェクトのアンカータグのhref値(URL)にこだわっています。私も他のものを掻き集めているので、残りは無視してください。ここで私はこれまで持っているものである:ここではRubyでのアンカーのhref値の掻き立て
def self.scrape_index_page(index_url) #responsible for scraping the index page that lists all of the students
#return an array of hashes in which each hash represents one student.
html = index_url
doc = Nokogiri::HTML(open(html))
# doc.css(".student-name").first.text
# doc.css(".student-location").first.text
#student_card = doc.css(".student-card").first
#student_card.css("a").text
end
は、学生のプロファイルのいずれかです。それらはすべて同じですので、href urlの値を調べるだけです。
<div class="student-card" id="eric-chu-card">
<a href="students/eric-chu.html">
<div class="view-profile-div">
<h3 class="view-profile-text">View Profile</h3>
</div>
<div class="card-text-container">
<h4 class="student-name">Eric Chu</h4>
<p class="student-location">Glenelg, MD</p>
</div>
</a>
</div>
ご協力いただきありがとうございます。
どのような質問ですか? –
'url'またはhtmlのドキュメントサンプルを共有してください – Abdullah
私は学生カードクラスのコンテナのhref値を取得しようとしています。 – alexnewby