I'm trying extract text from inbetween a TD tag using BeautifulSoup and requests in Python 2.7. So far using this code I get nothing :(
import requests
from bs4 import BeautifulSoup
# Set up the Spider
def card_search(max_pages):
page = 1
mtgset = 'portal'
card = 'lava-axe'
while page <= max_pages:
url = 'http://www.mtgotraders.com/store/search-results.html?q=lava+axe&x=0&y=0'
source_code = requests.get(url)
plain_text = source_code.text
soup = BeautifulSoup(plain_text)
for text in soup.findAll('td',{'class': 'price mod'}):
pagetext = text.get('td')
print(pagetext)
page += 1
card_search(1)
I'm trying to automate sorting and value my MTG card collection so results from the site used in the code example are pretty important. I know the site can be parsed because I got it to return links. Sadly, I just can't get plain text to happen.
Here is the code used to pull links, but its not directed at the table. Just the page itself.
import requests
from bs4 import BeautifulSoup
# Set up the Spider
def card_search(max_pages):
page = 1
mtgset = 'portal'
card = 'lava-axe'
while page <= max_pages:
url = 'http://www.mtgotraders.com/store/search-results.html?q=lava+axe&x=0&y=0'
source_code = requests.get(url)
plain_text = source_code.text
soup = BeautifulSoup(plain_text)
for text in soup.findAll('a'):
pagetext = text.get('href')
print(pagetext)
page += 1
card_search(1)
Kind Regards, Sour Jack