Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

scrapy with selenium

import scrapy
from selenium import webdriver

class ProductSpider(scrapy.Spider):
    name = "product_spider"
    allowed_domains = ['ebay.com']
    start_urls = ['http://www.ebay.com/sch/i.html?_odkw=books&_osacat=0&_trksid=p2045573.m570.l1313.TR0.TRC0.Xpython&_nkw=python&_sacat=0&_from=R40']

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

    def parse(self, response):
        self.driver.get(response.url)

        while True:
            next = self.driver.find_element_by_xpath('//td[@class="pagn-next"]/a')

            try:
                next.click()

                # get the data and write it to scrapy items
            except:
                break

        self.driver.close()
Comment

PREVIOUS NEXT
Code Example
Python :: reading from a text file 
Python :: how to find the last element of list in python 
Python :: create an empty list in python 
Python :: print list of list line by line python 
Python :: convert date to string in python 
Python :: leetcode python 
Python :: plotly express change legend labels 
Python :: js choice function 
Python :: pandas df mode 
Python :: python string variable 
Python :: python functools 
Python :: convert python code to pseudocode online 
Python :: subtract from dataframe 
Python :: argparse one argument or without argument 
Python :: path in python 
Python :: how to test that an exception was raise using pytest 
Python :: python nested object to dict 
Python :: instance of object 
Python :: how to connect mongodb database with python 
Python :: docker hub python 
Python :: add new element to python dictionary 
Python :: how to create multiple columns after applying a function in pandas column python 
Python :: create anaconda env 
Python :: map python 
Python :: how to change title font size in plotly 
Python :: replace NaN value in pandas data frame with zeros 
Python :: copy something character ubntil a specific character in python 
Python :: something useless. python 
Python :: b-spline quantile regression with statsmodels 
Python :: pythoon 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =