我正在使用Scrapy和Python进行网络编写,并且无法编写正确的xpath命令来从此URL中提取完整的事件描述:[https://www.......com/events/9275-big-talks]没有任何不必要的字符,但它正在获取许多不必要的字符,如'',' \ r \ n'等我正在写这个命令:
response.xpath('//*[@class = "events-discription-block"]//*/text()').extract()
获得此输出:
['Event Description',
'The Theme of the conference will be ‘Learn from Leaders’, where Industry experts and great influential leaders will address. This Conference will deliver an exceptional speaks. The concept or the idea is to connect great leaders to the one who are looking for guidance in their life. A ‘Social Experiment’ to provide a platform for sharing success stories and ideas, empowering people to work towards their dreams from great leaders.',
' ',
'Agenda:',
' 09:00 am – 09:30 am: Registration & Welcome Note by Organizers.',
' ',
'09:30 am to 10:00 am: Innovation & story of Lakshmi asu machine By Padamashri Chintakindi Mallesham (Handloom Weaver).',
' ',
'10:00 am to 10:25 am: A Moment of Choice By Vyjayanti Vasanta Mogli (Transgender Activists).',
' ',
'10:25 am to 10:50 am: Back to the Roots By Dr. G V Ramanjaneyulu (Agriculturist).',
' ',
'10:50 am to 11:00 am: Snacks break.',
' ',
'11:00 am to 11:25 am: Journey Bonded to Psoriasis By Munipally Snigdha (Youngest poets in the poetry circuit).',
' ',
'11:25 am to 11:50 am: Startups how to raise Funds By Suman Gandham (Venture Capitalist. Barcelona, Spain).',
' ',
'11:50 am to 12:15 pm: Qualities Of The Most Effective Leaders By Mir Mahmood Ali (Leadership Motivator).',
' ',
'12:15 pm to 12:45 pm: Entrepreneur Journey By Sri Charan Lakkaraju (Entrepreneur).',
' ',
'12:45 pm to 01:00 pm: Announcements / Networking / Closing Note. ',
'Rules & Regulations:',
'\r\n',
'Attendees must carry a print out of the booking confirmation for entry inside the venue.',
'\r\n',
'Each ticket / confirmation admits one person only.',
'\r\n',
'Event doors will remain closed during sessions and will not open for entry.',
'\r\n',
'Attendees reaching late at the venue will NOT be allowed inside the auditorium.',
'\r\n',
'The attendees must wear their conference badge throughout the event.',
'\r\n',
'All registrations are subject to verification, any discrepancy may result in cancellation of registration.',
'\r\n',
'All attendees must carry a valid government verified photo identity card like: Aadhar Card, Pan Card, Driving License, Passport, etc.',
'\r\n',
'Tickets once booked are non-refundable & non-transferable. Cancellation and rescheduling of registration is not allowed.',
'\r\n',
'There will be ‘NO’ Q&A and audience to speaker interaction on stage.',
'\r\n',
'There will be adequate breaks for networking and refreshments.',
'\r\n',
'No photography or video recording at the venue is permitted, under any circumstances.',
'\r\n',
'Consumption of any prohibited substances is strictly prohibited at the venue. Carrying of food items, alcohol, cigarettes, inflammable and banned substances is strictly prohibited.',
'\r\n',
'The organizer does not take any responsibility for injuries, loss or theft of any personal belongings.',
'\r\n',
'Children under the age of 16 will not be allowed at the venue unaccompanied.',
'\r\n',
'All standard venue and attendee rules are applicable.',
'\r\n',
'Guests who do not report for registration will have to forfeit their ticket. The ticket cannot be transferred to anyone else. The attendee has agreed to these terms before registration. The organizer can reassign the seat to a guest on the waiting list.',
'\r\n',
'Bulk booking or nameless booking is not permitted by individuals. Registration will be canceled and made void.',
'\r\n',
'No parking is available inside the venue. Please plan accordingly. We encourage you to use public transport.',
'\r\n',
'We encourage you to car pool or share your car with other attendees. Find #BigTalksCarpool online on Twitter.',
'\r\n',
'By registering and making a payment you agree that all details provided are accurate. A holder of any duplicate or forged passes/badges/tickets will be handed over to the police personnel. Forging passes is a criminal offence.',
'\r\n',
'Gadget usage: Switch off your mobile phone or place it in the silent mode during the show.',
'\r\n',
'Onsite help: Our Team will be available onsite to help you with the arrangements and information.',
'\r\n',
' ']
如何摆脱这些角色?请帮帮我!
答案 0 :(得分:1)
考虑删除不必要的char的building an input processor of ItemLoader。例如,我正在使用:
def remove_escapes(value):
string.replace(value, "\n", " ")
string.replace(value, "\t", " ")
return value