How to read text and get some specific lines values using Scrapy

107 Views Asked by At

I have a requirement to hit url > http://something.com/requirements.txt Content will be something like this, (response.text).

    From the 8th to the 12th century, Old English gradually transformed through language contact into Middle English. Middle English is often arbitrarily defined as beginning with the conquest of England by William the Conqueror in 1066, but it developed further in the period from 1200–1450.
    
Year: 2020

    First, the waves of Norse colonisation of northern parts of the British Isles in the 8th and 9th centuries put Old English into intense contact with Old Norse, a North Germanic language. Norse influence was strongest in the north-eastern varieties of Old English spoken in the Danelaw area around York, which was the centre of Norse colonisation; today these features are still particularly present in Scots and Northern English. However the centre of norsified English seems to have been in the Midlands around Lindsey, and after 920 CE when Lindsey was reincorporated into the Anglo-Saxon polity, Norse features spread from there into English varieties that had not been in direct contact with Norse speakers. An element of Norse influence that persists in all English varieties today is the group of pronouns beginning with th- (they, them, their) which replaced the Anglo-Saxon pronouns with h- (hie, him, hera).[43]

i want to scrape only "Year:" value from the text response using scrapy and map that to ItemLoader. Is there any way i can do with scrapy?

1

There are 1 best solutions below

0
On

You can use regex re.

import re

re.findall(r'Year: (.*)\n', response.text)