N
N
Nikita Kornilov2019-12-19 12:26:32
JavaScript
Nikita Kornilov, 2019-12-19 12:26:32

How to make the parser follow links?

Good afternoon experts!
More recently, I asked a question about which tool to use to write an easy and simple data parser from a site. We talked about Osmosis and Simple HTML DOM. Good stuff, but I have one more little question about them. How can you make these parsers enter data into fields and click buttons on the site?
In particular, you need to enter the VIN number of the car on the site with spare parts , press the search button, go to a specific section and take the numbers of certain parts from there. How can this be implemented? I thought to substitute the VIN number in the address bar so that there was a GET request, but the search generates a link like https://site/model/numbers/letters:and:numbers/?vin=numbers,and you can't create it yourself. In general, I don’t understand how to make the parser use the search on the site and enter the desired section.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Valeron Sergeev, 2019-12-19
@Nikkorfed

If you look closely, there is a function called

function searchVIN() {
  var vin = $('input#search-vin').val()
  if (vin.length == 0) {
    alert('Не указан ВИН автомобиля')
    $('input#search-vin').focus()
    return
  }

  if ((vin.length != 7) && (vin.length != 17)) {
    alert('Неверная длина ВИН автомобиля. Должно быть 7 или 17 символов')
    $('input#search-vin').focus()
    return
  }

  $('input#search-vin').attr('disabled', 'disabled')
  $.post(
    '/ajax_vin_bmw.php',
    {
    	'vin': vin
    },
    function (s) {
    	if (s.substr(0,1) == '/') {
    		document.location.href = s
    	} else {
    	  alert(s)
    	  $('input#search-vin').removeAttr('disabled')
    	}
    }
  )
}

those. you also send a post request to /ajax_vin_bmw.php with the content vin=YourVin , get a response and parse as usual

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question