I'm currently getting this error and don't know what is means. Its a scrapy python project, this is the error I'm seeing:
File "/bp_scraper/bp_scraper/httpmiddleware.py", line 22, in from_crawler
return cls(crawler.settings)
File "/bp_scraper/bp_scraper/httpmiddleware.py", line 12, in __init__
if parts[1]:
TypeError: '_sre.SRE_Match' object has no attribute '__getitem__'
The code:
import re
import random
import base64
from scrapy import log
class RandomProxy(object):
def __init__(self, settings):
self.proxy_list = settings.get('PROXY_LIST')
f = open(self.proxy_list)
self.proxies = {}
for l in f.readlines():
parts = re.match('(\w+://)(\w+:\w+@)?(.+)', l)
if parts[1]:
parts[1] = parts[1][:-1]
self.proxies[parts[0] + parts[2]] = parts[1]
f.close()
@classmethod
def from_crawler(cls, crawler):
return cls(crawler.settings)
Thanks in advance for your help!