Python Forum
How to implement APScheduler in Python 3.6?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to implement APScheduler in Python 3.6?
#5
following is the content of my python script-
def get_soup(url):
soup = None
try:
    response = requests.get(url)
    if response.status_code == 200:
        html = response.content
        soup = BeautifulSoup(html, "html.parser")
    return soup

def get_category_urls(url):
soup = get_soup(url)
cat_urls = []
try:
    categories = soup.find('div', attrs={'id': 'menu_oc'})
    if categories is not None:
        for c in categories.findAll('a'):
            if c['href'] is not None:
                cat_urls.append(c['href'])
    return cat_urls

def get_product_urls(url):
 soup = get_soup(url)
 prod_urls = []
 if soup.find('div', attrs={'class': 'pagination'}):
     for link in soup.select('div.links a'):
         if link.string.isdecimal():  # dump next and last links
             prod_urls.append(link['href'])
 print("Found following product urls::", prod_urls)
 return prod_urls

if __name__ == '__main__':
category_urls = get_category_urls(URL)
product_urls = get_product_urls(URL)
#TODO upload in db
Now I have created a scheduler-refresh.py with following content
import schedule
import time
def job():
    //how to call myfile.py here?
    print("refreshing...")
schedule.every().week.at("10:30").do(job)
while 1:
    schedule.run_pending()
    time.sleep(1)
Here I don;t know how to call myfile.py. Can you help me?
Reply


Messages In This Thread
RE: How to implement APScheduler in Python 3.6? - by PrateekG - Jun-05-2018, 10:13 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to use python to implement one QA task taiqixp 2 3,702 Jan-10-2018, 12:28 PM
Last Post: squenson

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020