how can i write a non-stop crawler with python and run it on a server? [closed]

  • Last Update :
  • Techknowledgy :

Here is an example daemon that writes the time to a file.

import daemon
import time

def do_something():
   while True:
   with open("/tmp/current_time.txt", "w") as f:
   f.write("The time is now " + time.ctime())
time.sleep(5)

def run():
   with daemon.DaemonContext():
   do_something()

if __name__ == "__main__":
   run()

Suggestion : 2

I want to write a scraper with python that anycodings_python crawl some urls and scrape and save datas. I anycodings_python know how can I write it as a simple program. anycodings_python I'm looking for a way to deploy it on my anycodings_python virtual server (running ubuntu) as a service anycodings_python to make it non-stop crawling. Could any one anycodings_python tell me How can I do this?,What you want to do is daemonize the anycodings_service process. This will be helpful in anycodings_service creating a daemon.,Saving data to notepad and compiling additional saves into existing data,Here is an example daemon that writes anycodings_service the time to a file.

Here is an example daemon that writes anycodings_service the time to a file.

import daemon
import time

def do_something():
   while True:
   with open("/tmp/current_time.txt", "w") as f:
   f.write("The time is now " + time.ctime())
time.sleep(5)

def run():
   with daemon.DaemonContext():
   do_something()

if __name__ == "__main__":
   run()

Suggestion : 3

Published On:   June 8, 2020

You can find the right values for these by inspecting your web traffic using Chrome Developer Tools, or a tool like MitmProxy or Wireshark. You can also copy a curl command to your request from them. For example

curl 'https://scrapeme.live/shop/Ivysaur/'\ -
   H 'authority: scrapeme.live'\ -
   H 'dnt: 1'\ -
   H 'upgrade-insecure-requests: 1'\ -
   H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36'\ -
   H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9'\ -
   H 'sec-fetch-site: none'\ -
   H 'sec-fetch-mode: navigate'\ -
   H 'sec-fetch-user: ?1'\ -
   H 'sec-fetch-dest: document'\ -
   H 'accept-language: en-GB,en-US;q=0.9,en;q=0.8'\
   --compressed

Here is how this was converted to python

import requests
headers = {
   'authority': 'scrapeme.live',
   'dnt': '1',
   'upgrade-insecure-requests': '1',
   'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36',
   'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
   'sec-fetch-site': 'none',
   'sec-fetch-mode': 'navigate',
   'sec-fetch-user': '?1',
   'sec-fetch-dest': 'document',
   'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8',
}
response = requests.get('https://scrapeme.live/shop/Ivysaur/', headers = headers)