Я сделаю это просто. У меня есть страница входа. Я вхожу Я вижу домашнюю страницу. На главной странице есть две ссылки. Я хочу открыть эти две ссылки. Каждая ссылка имеет две данные. Я просто хочу четыре данных из двух ссылок, которые находятся на главной странице, которая также появляется после входа в систему. Я могу перейти к шагу ссылки. Я могу удалить ссылку, но не данные внутри ссылки. Как я могу это сделать? Спасибо
Мой скрап-код: P.S. Я просто сделал это по собственной интуиции, я не знаю, возможно ли это.
import scrapy
class ClassroomSpider(scrapy.Spider):
name = 'classroom'
start_urls =['http://classroom.dwit.edu.np/login/index.php']
login_url = 'http://classroom.dwit.edu.np/login/index.php'
def parse(self, response): //code to login into the website
data = {
'username': mynameisaj
'password': somerandomvalue
}
yield scrapy.FormRequest(url=self.login_url,formdata = data, callback = self.parse_quotes)
def parse_quotes(self,response):
Link = response.xpath('//*[@class="event"]/a/@href').extract() //link in the homepage
for item in zip(Link):
scraped_info = {
'Link':item[0],
}
yield scraped_info
next_page_url = response.xpath('//*[@class="event"]/a/@href').extract() // link in the homepage
if next_page_url:
yield scrapy.Request(url = next_page_url, callback = self.parse_data)
def parse_data(self,response):
Data = response.xpath('//*[@class="no-overflow"]/p/text()').extract() //data inside the link in the homepage
for item in zip(Data):
scraped_info1 = {
'Data':item[0],
}
yield scraped_info1
ОБНОВЛЕНИЕ
Элемент html:
<div id="intro" class="box generalbox boxaligncenter"><div class="no-overflow"><p>1) Write a program to print the area and perimeter of a triangle having sides of 3, 4 and 5 units by creating a class named 'Triangle' without any parameter in its constructor.</p>
<p><br>2) Write a program that would print the information (name, year of joining, salary, address) of three employees by creating a class named 'Employee'. <br>Create properties as needed for Employee class and set values to those properties using constructor with arguments.</p>
<p>The output should be as follows:</p>
<table border="0" style="width: 348px; height: 43px;">
<tbody>
<tr>
<td><strong><span data-mce-mark="1">Name</span></strong></td>
<td><strong><span data-mce-mark="1">Year of joining</span></strong></td>
<td><strong><span data-mce-mark="1">Address</span></strong></td>
</tr>
<tr>
<td><span data-mce-mark="1">Robert</span></td>
<td><span data-mce-mark="1">1994</span></td>
<td><span data-mce-mark="1">64C- WallsStreet</span></td>
</tr>
<tr>
<td><span data-mce-mark="1">Sam</span></td>
<td><span data-mce-mark="1">2000</span></td>
<td>Kathmandu</td>
</tr>
</tbody>
</table>
<p></p>
<p>3) Create a class 'Degree' having a method 'getDegree' that prints "I got a degree". It has two subclasses namely 'Undergraduate' and 'Postgraduate' each having a method with the same name that prints "I am an Undergraduate" and "I am a Postgraduate" respectively. Call the method by creating an object of each of the three classes.</p>
<p>Note: Use separate class with main method</p></div></div>
Все, что было списано, было последним элементом p.