GithubHelp home page GithubHelp logo

Comments (2)

hadley avatar hadley commented on August 22, 2024

Maybe you need html_nodes? html_node only returns a single node.

On Sunday, October 12, 2014, notesofdabbler [email protected]
wrote:

I am not sure what I am doing wrong but when I scrape a page from
realtor.com, I am not getting the full list with rvest. I have listed my
R code below.

Scrape data on house listings from realtor.com

set working directory

setwd("~/notesofdabbler/Rspace/dayoh_housing/")

load libraries

library(rvest)
library(XML)

Search URL with following filter applied

3+ bedrooms, 2+ baths, 1800+ sqft, 0-20 years old

srchurl="http://www.realtor.com/realestateandhomes-search/Centerville_OH/beds-3/baths-2/sqft-8/pfbm-10/show-hide-pending"

using XML library

housedoc=htmlTreeParse(srchurl,useInternalNodes=TRUE)
ns_id=getNodeSet(housedoc,"//ul[@Class='listing-summary']//li[@Class='listing-location']//a[@href]")
id=sapply(ns_id,function(x) xmlAttrs(x)["href"])
id

using rvest library

housedoc = html(srchurl)
houselist = housedoc %>% html_node(".listing-summary")
id = houselist %>% html_node(".listing-location a") %>% html_attr("href")
id

The actual run version of the code with output is here
http://notesofdabbler.github.io/other/scrape_housingdata.html.


Reply to this email directly or view it on GitHub
#21.

http://had.co.nz/

from rvest.

notesofdabbler avatar notesofdabbler commented on August 22, 2024

Thanks very much. changing to html_nodes fixed it. Just for reference I have put the corrected version of the code here

from rvest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.