[Beginner] Link Scraping script with somes problems

DenoNeci

Newbie
Joined
Dec 27, 2020
Messages
37
Reaction score
14
Hi, first of all I'm a beginner in programming. I wanted to create a small python program to scramble the download links from pornbb forum.

My problem is an addition problem, I have to add +15 to the links when I switch to a newer page.

I'm putting screenshots. Can you help me please :) ?
 

Attachments

  • Topic 1.PNG
    Topic 1.PNG
    2.9 KB · Views: 137
  • 2.PNG
    2.PNG
    5.5 KB · Views: 151
  • 3.PNG
    3.PNG
    5.8 KB · Views: 142
  • 4.PNG
    4.PNG
    5.2 KB · Views: 169
  • Code.PNG
    Code.PNG
    97.1 KB · Views: 141
In your loop your variable "p" starts from 0 and increment until 268. Imagine this variable is the page number, but page 0 is the first page for you and not page 1 like normal.
You know that you will have to add +15 to the url from the second page.
So:
1)You will multiplicate your current page number with 15 and will keep the result in a new variable after the loop start(before the "url" variable) , ex: newvar = p*15

2)After the variable declaration on the next line you need to see if your "newvar" is bigger than 0!

if var "newvar" is bigger than 0:
the variable "url" will hold the url from your last photo "Code.PNG" but instead of '+ 15+ str(p)+' you replace with '+str(newvar)+'
else:
the variable "url" will hold the naked link(original one like in your first photo, Topic 1.PNG)

3) Why we need to check if newvar is bigger than 0? Because for page 0 "newvar" will be 0 (the result of the ecuation p*15), and from page 1 newvar will be a multiple of 15, like 15, 30, 45, etc.

I hope you understand my english!
 
In your loop your variable "p" starts from 0 and increment until 268. Imagine this variable is the page number, but page 0 is the first page for you and not page 1 like normal.
You know that you will have to add +15 to the url from the second page.
So:
1)You will multiplicate your current page number with 15 and will keep the result in a new variable after the loop start(before the "url" variable) , ex: newvar = p*15

2)After the variable declaration on the next line you need to see if your "newvar" is bigger than 0!

if var "newvar" is bigger than 0:
the variable "url" will hold the url from your last photo "Code.PNG" but instead of '+ 15+ str(p)+' you replace with '+str(newvar)+'
else:
the variable "url" will hold the naked link(original one like in your first photo, Topic 1.PNG)

3) Why we need to check if newvar is bigger than 0? Because for page 0 "newvar" will be 0 (the result of the ecuation p*15), and from page 1 newvar will be a multiple of 15, like 15, 30, 45, etc.

I hope you understand my english!
Thanks for answering me, I understand better now ^^.
 
Back
Top