
188 Text Mining and Visualization: Case Studies Using Open-Source Tools
8.6.7 Python Imports and Global Variables
At the very top of your simplecrawler.py file, some basic imports for the function of
Scrapy are needed. Additional imports for working with JSON, random numbers and copy-
ing are also needed. The following code should be added to the top of your file:
1 from scrapy import Spider
2 from scrapy.selector import HtmlXPathSelector
3 from scrapy.selector import Selector
4 import json
5 from random import randint
6 import random
7 import unicodedata
8 import copy
Just below this code, a collection of global variables need to be added. These include the ...