S
S
sddvxd2017-01-18 19:35:14
Python
sddvxd, 2017-01-18 19:35:14

How does online sites work (working with requests)?

Good evening
How does the web server process the online site? I don't think that just getting the page helps to increase online (tested with my code)

import requests

url = "http://example.com"
iterator = 0

proxyList = ["120.92.3.127:80","47.89.41.164:80","14.199.124.204:80", "121.40.108.76:80", "120.52.73.112:8090",
             "120.52.73.97:8090", "47.90.74.111:8088", "146.185.148.95:3128", "139.59.136.83:3128", "139.59.136.45:8080",
             "70.248.28.23:800", "138.68.141.243:3128", "138.68.49.239:8080"]




while True:

    if len(proxyList) == (iterator):
        print("прошел по массиву")
        iterator = 0

    proxyDict = {"http": "http://" + proxyList[iterator]}
    try:
        result = requests.request("GET", url,  timeout = (5,10), proxies = proxyDict)
        print("Прокси " + proxyList[iterator] + " отработало!")
        iterator += 1
    except:
        print("Удаляю " + proxyList[iterator])
        proxyList.pop(iterator)

        pass


input()

Proxies work fine, I checked at httpbin.org/ip
If you know the answer, please share your experience

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Q
qlkvg, 2017-01-19
@qlkvg

Almost every week there are questions of this kind on the toaster, and every time the answer is the same - open the developer console in the browser and see what happens there. You don’t understand what GET, POST and the numbers next to them are - https://ru.wikipedia.org/wiki/HTTP. Not aware of ajax - https://ru.wikipedia.org/wiki/AJAX. I heard about crsf, but you still can't remember what it means and how to deal with it - https://en.wikipedia.org/wiki/Cross-site_request_f... And so on until you comprehend enlightenment.
And only then, when questions like "How to pass multipart / form-data in a POST request?" arise, you go to the toaster.

T
TyzhSysAdmin, 2017-01-18
@POS_troi

If about visit counters, then what you are doing will not help you.
Nowadays, all (well, or most) counters are based on JavaScript and it’s not enough for you to just get the page, you need to process it like a browser - execute JS scripts at least

S
shamanovski, 2017-01-19
@shamanovski

The proxyDict dictionary is better defined before the start of the loop, rather than collecting a mutable object during each iteration.
iterator is an object. In your case, it's better to name the variable iteration
According to PEP8, the name of a function argument is not separated by spaces from its value.
Exceptions should be caught immediately after the statement in which they are supposed to take place.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question