mercredi 4 septembre 2019

How to scrap images and titles from Imgur with nokogiri

I'm trying to scrap the images and the titles of https://imgur.com/t/memes with Nokogiri.

This is for a little project, i've already used Nokogiri for scrapping https://www.reddit.com/r/memes/ before, and it worked great.

require 'rest-client'
require 'nokogiri'

page = RestClient.get('https://imgur.com/t/memes')
doc = Nokogiri::HTML.parse(page)
posts = doc.css('.Post-item')

The css class that I need it's called '.Post-item', i have also tried with doc.search, and with 'Post-item' instead of '.Post-item', also i've tried with other css classes of that page, and all of them are returning me [], it should be returning a Nokogiri Parse on that class with all of the posts on that page.




Aucun commentaire:

Enregistrer un commentaire