Is there a way to scrape data from a website until 'X' string is found?

Hi all,

As the title of the post states, Im trying to scrape data from a website until a certain string is found, then stop.

Regards in advance!

JP

Nope, we cannot stop screen scrapping if found a particular string. For this scrap whole data and with use of string index method we can get the required data.

1 Like

Hey vish, thanks for the quick reply.

Could you please explain what do you mean by “with use of string index method we can get the required data”?

Regards!

It all depends on the data scraping approach you adopt and the type/Element you are scraping. If you share the page and the string, we will try to help.

Thanks

Hello @tsielk ,

Consider this string as an input,

String sampletext=“As they rounded a bend in the path that ran beside the river, Lara recognized the silhouette of a fig tree atop a nearby hill. The weather was hot and the days were long. The fig tree was in full leaf, but not yet bearing fruit.
Soon Lara spotted other landmarks—an outcropping of limestone beside the path that had a silhouette like a man’s face, a marshy spot beside the river where the waterfowl were easily startled, a tall tree that looked like a man with his arms upraised. They were drawing near to the place where there was an island in the river. The island was a good spot to make camp. They would sleep on the island tonight.”

now you want the ending index number which can be get by using LastIndex = sampletext.Index(“tonight”)
and text until “1500s” by using requiredindex = sampletext.Index(“1500s”) we can get the index number of 1500s text.

now keep “requiredindex” in “LastIndex” you can get the required text.

you can refer to the following links,

cheers @tsielk