How to monitor inventory movements in real time

Source: Internet
Author: User

1 ImportUrllib2 ImportOS3  fromBs4ImportBeautifulSoup4 ImportDifflib5 Import Time6 7  while(1):8     ifOs.path.exists ('D:/new.txt') andOs.path.exists ('D:/old.txt'):9Os.remove ('D:/old.txt')Ten     ifOs.path.exists ('D:/new.txt'): OneOs.rename ('D:/new.txt','D:/old.txt') AURL ='http://www.zhenxin520.com/trends.asp?id=95' -Response =urllib.urlopen (URL) -Soup =BeautifulSoup (response) theText = Soup.find_all ("TD", attrs={"class":"Text3"}) -F1=open ('D:/new.txt','w+') - f1.write (str (text)) - f1.close () +     if  notOs.path.exists ('D:/old.txt'): -        Continue +F1=open ('D:/new.txt','R') AF2=open ('D:/old.txt','R') atF3=open ('D:/diff.txt','w+') -D=Difflib. Differ () -f1_lines=F1.readlines () -f2_lines=F2.readlines () -diff=list (D.compare (f1_lines,f2_lines)) -Diff2=list (D.compare (f2_lines,f1_lines)) ini =-1 -      forLineinchdiff: toI+=1 +Line2 =Diff2[i] -       ifline[0]=='-': the          Try: *Start = Line.index ('D') $Start2 = Line2.index ('D')Panax NotoginsengSUBSTR =Line[start:] -SUBSTR2 =Line2[start2:] theRMSTR = ['<span>','</span>','<br/>','</p>'] +              forJinchRmstr: Asubstr = Substr.replace (J,"') theSUBSTR2 = Substr2.replace (J,"') +F3.write ('New---'+substr+'\nold---'+substr2+'\ n') -          except: $             Continue $ f3.close () - f2.close () - f1.close () theTime.sleep (600)

Differ.txt Output Results:

New---D012 red: male l*7 xl*3 xxl*22 female m*2 child 4*7

Old ---D012 red: male l*7 xl*4 xxl*22 female S M L child 4*9

How to monitor inventory movements in real time

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.