0
0

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 5 years have passed since last update.

ruby on railsのスクレイピングについて質問です。

Posted at

この中のhref属性のアドレスを取得したいのですが、
mechanizeオブジェクトのserachメソッドでidを取得条件に入れ
ることができません。何か方法はありますでしょうか?


agent = Mechanize.new
current_page = agent.get("取得先のwebサイトのアドレス")
elements = current_page.search("div#main")

elements.each do |ele|
links << ele.get_attribute('href')
puts links
end

linksの中身がnullで、うまく取得できていません。

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?