Retrieve information by clicking on a hyperlink in JavaScript

Is it possible to extract content from a website that uses "onClick" instead of "href" in hyperlinks, resulting in the same URL regardless of the page being viewed?

The specific content I'm attempting to retrieve is located under "Alimentação" > "Estudantes".

<a href="#" onclick="return go('','4;02');" title="Estudantes">Estudantes</a>

Can Jsoup help with extracting this content?

Answer №1

Utilizing Jsoup to establish a connection with the specified URL and submitting data parameters such as "nav", "index@4;02", "opt", "4;02", and "chvP", "127" using the post() method.

Answer №2

If you need to retrieve the onclick value using Jsoup, you can do so easily. Check out this link for more information:

Simply swap out this line of code:

String linkHref = link.attr("href");

with the following:

String handler = link.attr("onclick");

However, keep in mind that after obtaining the onclick value, it may be challenging to reconstruct the URL unless you can somehow correlate the magic number to 4,02.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Iterate through a local storage object using JavaScript's looping mechanism

I am currently working on a project to create a shopping cart using local storage. I have initialized the local storage with the following code: var cart = {}; cart.products = []; localStorage.setItem('cart', JSON.stringify(cart)); I then use ...

Ways to append multiple values to an object ID in mongoDB at a later time

I have a pre-existing object ID in my MongoDB database, and I am looking to add more values inside it in the future. Here is an example of my current MongoDB structure: [{ label: 'colors', options: [ { label: 'Bl ...

Remove search results in real-time

I'm currently working on implementing a search feature for a web application. While I have made some progress, I am facing an issue with removing items when the user backspaces so that the displayed items match the current search query or if the searc ...

Is there a way to send an Ajax response to the web browser client as a downloadable file?

In my MVC 3 project, I have generated a csv file in an Action Method on the server named GetCSV() which is designated as an [HttpPost] action method. My goal is to send this csv file directly to the web browser for download. While I was able to achieve t ...

What is the best way to iterate through one level at a time?

Imagine a scenario where the structure below cannot be changed: <xml> <element name="breakfast" type="sandwich" /> <element name="lunch"> <complexType> <element name="meat" type="string" /> <element name="vegetab ...

Basic JavaScript framework centered around the Document Object Model (DOM) with a module structure similar to jQuery. Currently facing challenges with

In order to create a simple framework with jQuery style, I have written the following code: (function(window) { window.smp=function smpSelector(selector) { return new smpObj(selector); } function smpObj(selector) { this.length = 0; if (!s ...

Exploring Polynomial Derivatives using HashMaps: The Best Way to Traverse HashMap<Degree, Coeff>?

I am looking to create a derivative method for polynomials using a HashMap to store the degree and coefficient. This approach is more space-efficient compared to using an Array, especially when dealing with polynomials containing numerous zero coefficien ...

Encountering a timeout error while using selenium-webdriver and phantomJS

Currently, I am developing my automated test scripts using a combination of selenium-webdriver, phantomJS, and mocha. The script I am working on is written in JavaScript. One requirement is to wait until a specific element becomes completely visible befo ...

Issue while rendering Vuex

Currently in the process of setting up a project using Vuex and Vue, I have encountered a peculiar issue. It seems to be related to the order of rendering, but despite multiple attempts to modify the code, the problem persists. My approach involved access ...

Unable to access data from the Array by passing the index as an argument to the method

Having trouble retrieving an item from an Array using method() with an index argument that returns undefined export class DataService { public list = [ { id: 11, name: 'Mr. Nice' }, { id: 12, name: 'Narco' }, ...

The cookie's expiration time is being set to 1 hour, rather than the specified maxAge duration

My file contains a cookie that consistently sets to 1 hour as the default, even when I specify a maxAge of 12 seconds. res.cookie("my-cookies", req.body.id_token, {maxAge: 12000, httpOnly: false}); ...

The jCapSLide Jquery Plugin is experiencing compatibility issues in Chrome browser

While this JQuery plugin works perfectly in Internet Explorer and Firefox, it seems to be malfunctioning in Chrome. The plugin is not being recognized at all by Chrome, and the captions are appearing below the image instead of on top with a sliding effect. ...

Editing in real time, yet no instance to be found

I have developed my own custom non-jQuery ajax solution for building web applications. Recently, I encountered compatibility issues with IE9 while using TinyMCE, so I am considering switching to CKeditor. The editable content is contained within a div str ...

How to lock the width of a column in Android to prevent resizing based on the longest content

I'm currently working on implementing a calendar view in my app. The structure includes a TableLayout with 8 individual TableRow elements: 6 for displaying the days from the current, previous, and next months. 1 for listing the days of the week (Sun ...

The reducer I have is inexplicably returning undefined even though I'm certain it was added to combineReducers

After countless hours of debugging, everything seems to be in working order but the problem still persists. The main reducer file is located at reducers/index.js // @flow import { combineReducers } from "redux"; import blocks from "./blocks"; import user ...

Certain devices may encounter an "end of input at character 0" error

I am encountering an issue with the code snippet below, where I am making an API call using PHP. The API returns JSON data, which I am storing in a stringBuilder object. The problem arises as it works fine on some carriers and devices, but throws a JSONExc ...

Is there a way to automatically hide a div based on a checkbox value when the page loads?

How can I hide a div in my view when a checkbox is not checked upon page load? <input type="checkbox" class="k-checkbox" id="chkInvoiceStatusActive" asp-for="InvoiceStatus" value="true" /> <input t ...

Incorporating a hyperlink into an Iframe triggered by Fancybox2-AJAX, specific to the Iframe's unique identifier

One thing I have noticed is that everything seems to be working fine up until the point where I try to load it through fancybox via AJAX. An example of it working statically: <iframe id="videourl1" width="640" height="340" src="" frameBorder="0">& ...

How can I create a custom Sweet Alert button in JavaScript that redirects to a specific webpage when clicked?

Here's what I have in my code: swal({ title: 'Successfully Registered!', text: "Would you like to proceed to the Log In page?", type: 'success', showCancelButton: true, confirmButtonColor: '#308 ...

How to show line breaks in MySQL text type when rendering in EJS

In my MySQL table, I have a column called PROJ_ABOUT with the type TEXT. I have inserted several rows into this column and now I am trying to display this information in my Express.js app using the ejs engine. <h2>About project</h2> <p> ...