Apologies for my lack of proficiency in English. As a beginner in scrapy, I am seeking guidance on an issue I encountered while trying to scrape a particular website. Below is the code for my spider:
import scrapy
from bs4 import BeautifulSoup as bs
class SomeSiteSpider(scrapy.Spider):
name = 'somesite'
def start_requests(self):
urls = [
'http://somesite.ru/proxies/'
]
for url in urls:
yield scrapy.Request(url=url, callback=self.parse)
def parse(self, response):
token = response.css('input[name="xf0"]::attr(value)').extract_first()
data = {
'xpp': '4',
'xf1': '4',
'xf0': token,
'xf2': '0',
'xf4': '0'
}
yield scrapy.FormRequest(url='http://somesite.ru/proxies/', formdata=data, callback=self.parse_proxy, method='POST')
def parse_proxy(self, response):
page = bs(response.body, "html.parser")
table = page.select('td[align="center"] > table[cellspacing="1"]')
table = bs(str(table), 'html.parser')
print(table.prettify())
I am aiming to extract the following information:
<font class="spy14">
"200.200.200.200"
<script type="text/javascript"></script>
<font class="spy2">:</font>
"8080"
</font>
However, the output from my spider includes some unexpected elements:
<font class="spy14">
200.200.200.200
<script type="text/javascript>
document.write("<font class=spy2>:<\/font>"+(l2k1o5^f6l2)+(j0s9i9^e5z6)+(i9w3m3^s9p6)+(g7u1q7^u1j0)+(h8x4r8^n4s9))
</script>
</font>
This site does not make use of AJAX requests.
For reference, here is an image showing the output generated by the spider: Spider Output Picture