Using selenium to extract data from websites featuring javascript elements

As a beginner in the world of web scraping and using Selenium, I am facing a challenge with a page that requires a JavaScript script on a button to navigate to the next page. I came across a snippet of code (Click a Button in Scrapy) on Stack Overflow, but unfortunately, I have been unable to get it to work.

from selenium import webdriver

import scrapy

class chSpider(scrapy.Spider):
    name = 'spidypy'
    allowed_domains = ['117.145.177.252']
    start_urls = ['http://117.145.177.252/login.do?method=enterPdamccx']

    def __init__(self):
        self.driver = webdriver.Firefox()

    def parse(self,response):

        self.driver.get('http://117.145.177.252/login.do?method=enterPdamccx')

        while True:
            try:
                next = self.driver.find_element_by_xpath('/html/body/form/div[3]/div/div/a')
                url = 'http://117.145.177.252/login.do?method=enterPdamccx'
                yield Request(url,callback=self.parse2)
                next.click()
            except:
                break

        self.driver.close()

    def parse2(self,response):
        print('you are here!')

I am encountering the following error message multiple times:

selenium.common.exceptions.WebDriverException: Message: connection refused

Answer №1

There is an onclick function attached to 'a', which can be triggered using the following syntax:

driver.execute_script('doMccx()')

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

Here is a unique rewrite of the text: "Finding and selecting a specific <li> element from a list (<ul>) can be achieved by using the findElemem

Struggling to automate the selection process and have the 2nd item automatically chosen when the div pops up, but encountering difficulties. I need 'Mr.' to be selected instead of '--None--'. Please provide assistance. The HTML code is ...

Creating a Recursive Facebook Page Data Scraper using Selenium and Node.js

I am trying to iterate through an array of Facebook page IDs and retrieve the code from each event page. However, I am encountering a problem where I only get the code of the last page ID in the array repeated multiple times. For example, if there are 3 ID ...

Issue with Vue 2: Promise does not resolve after redirecting to another page

Although I realize this question might seem like a repetition, I have been tirelessly seeking a solution without success. The issue I am facing involves a method that resolves a promise only after the window has fully loaded. Subsequently, in my mounted h ...

Cracking the code of the @ symbol within this particular context

https://github.com/react-dnd/react-dnd/blob/master/examples/04%20Sortable/Simple/Card.js I'm trying to comprehend the significance of the @ symbol in this example. This is meant to be a straightforward drag and drop demonstration, but the implementa ...

scrape particular data from a table using scrapy

Currently, I am utilizing scrapy to extract content from a website specifically located within a particular <td> tag. The guide provided demonstrates downloading all the information, however, I only require the data from one individual <td>. As ...

Press the 'enter' button to post your tweet with Greasemonkey

I am working on a Greasemonkey script that will automatically submit a tweet when the user presses the 'enter' key. The script works perfectly on a basic HTML page with some help from tips I found on this website. However, when I attempt to use t ...

Enhance the connectivity of Angular js by activating the link function post transclusion

I am facing an issue with Angular where I have two directives that need to be transcluded within each other. However, I am unable to access the DOM using a simple JQuery selector after the transclude function has been executed. Specifically, I need to comp ...

"Prevent further button clicks by disabling it after the initial click with ActionRowBuilder in Discord.Js

Encountering a puzzling issue where I am unable to disable a button after it has been clicked. The option to disable the button does not seem to appear. When attempting to deactivate the button, I utilize the following function: const row = new ActionRowBu ...

Using AngularJS ng-repeat with jQuery find yields a single element result

I'm in the process of developing my very first AngularJS application, and I've run into an issue with the jQuery find function. Essentially, what I'm attempting to do is utilize a custom HTML component that contains a list of buttons generat ...

Hidden content from Vue router view

My goal is to have the navigation pane overlaying the content of the page, but instead, it is being appended to the bottom where the end of the navigation drawer would be. I've experimented with different variations to display data using navigation dr ...

Executing Datalist's Delete Command through Page Methods Implementation

Recently, I came across an issue with my DataList and Update Panel on my webpage. I noticed a significant delay in response time after incorporating the Update panels... intrigued, I delved deeper into this phenomenon and found some interesting insights in ...

When the button is not clicked, the function method gets invoked in React

When I call the initiateVideoCall method first and have a button called turnOff, it seems to load first without clicking the button. I'm having trouble understanding the issue here. Can someone please help me? Thanks in advance. const constraints = {& ...

Gather all script tags and place them into an array

Here is a sample markup that I need help with: <p><span style="color: blue;">Yes this one now</span></p> <p><br></p> <p>The main configuration value is this</p> <p><br></p> & ...

Importing various libraries in C# based on specific requirements

Currently, I am working on creating a unit test in Selenium using Nunit. During the development of this unit test, I have come across multiple libraries that house various language translations for all the options available. Each library contains a class ...

What is the process for decoding HTML content that is wrapped within JSON data?

I have a web application built using asp.net that utilizes ajax calls. Below is the code snippet for my web method which successfully responds to the ajax call. ADController adc = new ADController(); DataTable dt = adc.GetGeneral(Convert.ToInt32(A ...

Retrieving objects based on a property that begins with any element from an array

I have a collection of contacts that I need to filter based on the country code. Specifically, I want to identify contacts whose phone numbers start with any of the selected country codes. var countries = ['1', '91', '55', &ap ...

Encountering an undefined response in API call using Fetch with Express Nuxt

I've hit a roadblock with a task involving Express, API, and Fetch. I'm utilizing Nuxt along with Shopify API endpoints to retrieve data such as orders. Below is my express API Endpoint which should return an array of objects (orders). const bod ...

Is Angular 11 Compatible with Internet Explorer 5?

Is there a way to make Angular 11 compatible with Internet Explorer 5? I am developing an angular solution for a client whose default browser is Internet Explorer running on version 5 (by default). Initially, I am not supposed to change any browser configu ...

React - Children components in an array not updating when props are modified within a callback function

The question may be a bit unclear, so let me provide further explanation. This is a personal project I am working on to improve my understanding of React basics and socket.io. Within this project, I have developed a CollapsibleList component and a NestedL ...

Tips on making a fresh form appear during the registration process

After clicking on a submit button labeled as "continue" within a form, a new form will appear for you to complete in order to continue the registration process. ...