TL;DR

Add a slash :

  details_url <- paste0("https://www.sgcarmart.com/new_cars/",html_attr(h,"href"))
  # --->          --->          --->          --->         ^

The Journey

  1. I ran your informant far enough to get the popularcars, and looked at the first gear one :
    h <- popularcars[[1]]
    h
    # {html_node}
    # 
    # [1] 
    \r\n < ... # [2]
    Toyota Corolla Altis
    details_url <- paste0("https://www.sgcarmart.com/new_cars",html_attr(h,"href")) details_url # [1] "https://www.sgcarmart.com/new_carsnewcars_overview.php?CarCode=12618"

    Like you, for me that URL returned 404 .

  2. I navigated ( in a boring, convention, browser ) to the main URL, looked at the reservoir for the page, and searched for 12618 :
  3. I right-clicked on the part and copied the “ connect localization. I found that it was :
    https://www.sgcarmart.com/new_cars/newcars_overview.php?CarCode=12618 <-- from the source
    https://www.sgcarmart.com/new_carsnewcars_overview.php?CarCode=12618  <-- from your code
    

BTW, you might find this a little easier to manage than a for closed circuit. Iteratively building a frame is dreadfully ineffective, and while it may not be bad for the 18 entries I found it, it 's not good in the long range ( if you can avoid it ) .

info <- lapply(popularcars, function(h) {
    details_url <- paste0("https://www.sgcarmart.com/new_cars/", html_attr(h,"href"))
    details <- read_html(details_url)
    html_text(html_node(details,".link_redbanner"))
  })

str(info)
# List of 18
#  $ : chr "Toyota Corolla Altis"
#  $ : chr "Hyundai Venue"
#  $ : chr "Hyundai Avante"
#  $ : chr "SKODA Octavia"
#  $ : chr "Honda Civic"
#  $ : chr "Mazda 3 Sedan Mild Hybrid"
#  $ : chr "Honda Jazz"
#  $ : chr "Kia Cerato"
#  $ : chr "Mazda CX-5"
#  $ : chr "Mercedes-Benz GLA-Class(Parallel Imported)"
#  $ : chr "Toyota Raize(Parallel Imported)"
#  $ : chr "Toyota Camry Hybrid(Parallel Imported)"
#  $ : chr "Mercedes-Benz A-Class Hatchback(Parallel Imported)"
#  $ : chr "Mercedes-Benz A-Class Saloon(Parallel Imported)"
#  $ : chr "Honda Fit(Parallel Imported)"
#  $ : chr "Mercedes-Benz C-Class Saloon(Parallel Imported)"
#  $ : chr "Mercedes-Benz CLA-Class(Parallel Imported)"
#  $ : chr "Honda Freed Hybrid(Parallel Imported)"

last point : while this is a worthwhile learn attempt, that website 's Terms of Service are clear to department of state : `` You agree that you will not : ... engage in mass automated, systematic or any form of extraction of the corporeal ( `` the Content '' ) on our Website ''. I assume your efforts are under that specify .

Leave a Reply

Your email address will not be published.