1

Hi all! I encountered such a problem, when #parsing a site, I need to collect links and text, but the problem is that the link is not written directly, but through the #js function in the #html code, then roughly speaking, I need to trigger the js function by passing her parameters. And yes, I need to call this function (I don’t know how). I can’t use Selenium, I write the code in #Python

This is my first time on the forum, and I’m just starting to master parsing, I would be very grateful for your answer🥺

function submit(key, title, value) { var url = document.location.href; if (document.location.href.indexOf('#') != -1) url = document.location.href.substring(0, document.location.href.indexOf('#')); if (value != '') document.location.href = url + "#" + value; else document.location.href = url; var form = document.getElementById('PostForm'); form.innerHTML = "<input type=\"hidden\" name=\"Key\">"; form.innerHTML += "<input type=\"hidden\" name=\"Title\">"; document.forms[1].Key.value = key; document.forms[1].Title.value = title; document.forms[1].action = "Groups.aspx"; document.forms[1].submit(); } 
<a href="javascript:submit('RJuzPlvdavwzyOu12R7PKQ==','название товара....','0');">название товара....</a> 
4
  • 1
    Similar question with the solution to use a headless browser. stackoverflow.com/questions/28147213/… - another for selenium: stackoverflow.com/questions/44010059/… Commented Mar 6, 2024 at 18:13
  • Another similar question which suggests using pyv8 stackoverflow.com/questions/10136319/… Commented Mar 6, 2024 at 18:14
  • I need it without simulating a browser, it is advisable to use the request library Commented Mar 6, 2024 at 18:21
  • 1
    Note that a lot of answers predate Playwright and instead talk about using Selenium: you probably want Playwright these days (which offers more browser options, and supports more of the modern JS patterns). Commented Mar 6, 2024 at 19:51

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.