I practice Scrapy and want to ask a question:
I know how to use def printTW when it out of the class
How can I calling it when I write it inside class ?
My code is here:
Please teach me
from scrapy.spider import Spider
from scrapy.selector import Selector
from yahoo.items import YahooItem
def printTW(original_line):
for words in original_line:
print words.encode('utf-8')
class MySpider(Spider):
name = "yahoogo"
start_urls = ["https://tw.movies.yahoo.com/chart.html"]
#Don't know how to calling this
#def printTW(original_line):
# for words in original_line:
# print words.encode('utf-8')
def parse(self, response):
for sel in response.xpath("//tr"):
movie_description = sel.xpath("td[@class='c3']/a/text()").extract()
printTW(movie_description)