1

I wrote a script to scrape some web data in Python27. But with certain websites, the script gets stuck and seems to run forever.

Is there a way to follow what it is working on while the script is running?

I would like to understand where it is getting stuck, or if in fact it is doing something.

I'm new python. But I'm a little more familiar with Ruby on Rails. So I'm imagining something like watching the console in Rails while navigating the app after launching with 'rails s'.

tim_xyz
  • 11,573
  • 17
  • 52
  • 97

2 Answers2

1

You can set up and use a transparent proxy (burpsuite) and check the logs where the script gets stuck. Incase you are using requests module, use the following code.

http_proxy  = "localhost:8080"
https_proxy = "localhost:8080"
proxyDict = { 
              "http"  : http_proxy, 
              "https" : https_proxy
            }

r = requests.get(url, headers=headers, proxies=proxyDict)
Sanidhay
  • 159
  • 12
0

If you are running the python script from the console, you could do something like this

example.py

while condition: 
    print "I'm inside the while loop"

After that, you are able to run

python example.py

And you must see "I'm inside the while loop" in the console till the condition become false. If you want print the value of a varible you have to follow the following steps:

variable      = 45
text_variable = "hello"

while condition: 
    print "{0} -- {1}".format(variable,text_variable)

Then you will see in the console

45 -- hello
45 -- hello 
# And so on, until the condition returns false
Luis González
  • 3,199
  • 26
  • 43