3

I'm trying to create a Python script to pull prices of Yugioh Card prices from tcgplayer.com using BeautifulSoup. When you search for a card on this website, it returns a page of search results with several prices from different sellers. My goal is to pull all of these prices. In the below example, I'm opening the search result for a card called "A" Cell Breeding Device:

import urllib2
from bs4 import BeautifulSoup
html = urllib2.open('http://shop.tcgplayer.com/productcatalog/product/show?newSearch=false&ProductType=All&IsProductNameExact=false&ProductName=%22A%22%20Cell%20Breeding%20Device')
soup = BeautifulSoup(html, 'lxml')
soup.find_all('span', {'class': 'scActualPrice largetext pricegreen'})

A few days ago, running the soup.find_all line correctly gave me the information I needed. However, running this now gives me an empty array []. I've searched pretty extensively about BeautifulSoup returning an empty array, but I'm not sure if any of them apply to me since it was working just fine a few days ago. Can someone help point me in the right direction? Thank you in advance!

2 Answers 2

4

You should use selenium to scrap using real browser:

from selenium import webdriver

driver = webdriver.Chrome('/path/to/chromedriver')
driver.get('http://shop.tcgplayer.com/productcatalog/product/show?newSearch=false&ProductType=All&IsProductNameExact=false&ProductName=%22A%22%20Cell%20Breeding%20Device')
prices = driver.find_elements_by_css_selector('.scActualPrice')
for element in prices:
    print(element.text)
driver.quit()
Sign up to request clarification or add additional context in comments.

Comments

0

This website uses a service called Incapsula. The website Developers configured Incapsula to prevent bots from accessing it's content.

I suggest you to contact their admins and request access or ask them for API.

3 Comments

Using selenium worked for me, but do you think it'll stop working in a few days as well?
With selenium you are actually opening browser and doing all the operation, so it should be fine for now.But may be in future there are chances.
And using selenium is not reliable

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.