Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Python Reading a Pastebin Raw

Start = 5 #Starts Reading at line 5
End = 10 #Stops Reading at line 10



URL = "https://pastebin.com/raw/"
contents = requests.get(URL).text.split('\n')

this is my current code to reading a pastebin, I was wondering if there was a way where i could start reading at a specific line and stop reading at the second specific line.

My pastebin looks something this

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

split gives you a list so just slice the list from start to end.

URL = "https://pastebin.com/raw/"
contents = requests.get(URL).text.split('\n')[start:end]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading