Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the automatic order grabbing function of Taobao based on sikuli jar package in Python

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you how to realize the automatic order grabbing function of Taobao based on sikuli jar package in Python, the content is concise and easy to understand, it can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

I remember that before the festival, Brother Xi asked me if I could help write a Taobao automatic order grabbing function. In fact, it has been mentioned before that the sikuli IDE tool can easily achieve graphical automation, but it was not really implemented in python at that time.

So this is a good opportunity to get more familiar with the use of python and sikuli frameworks.

[the effect is as follows]

The following actions are all done by the code that simulates the user's mouse operation. At present, only automatically open the browser and add the goods to the shopping cart, the follow-up functions need to be optimized and realized.

[sample code]

# coding=utf-8# @ Auther: "Pengge thieves are excellent" # @ Date: 2019 @ Software: PyCharm

From jpypeimport * import jpypeimport time

Url = 'https://detail.ju.taobao.com/home.htm?spm=608.2291429.102212b.1.68864f84xeZhgw&id=10000503777283&item_id=539686923712'jvmPath = jpype.get_default_jvm_path () jpype.startJVM (jvmPath,'-ea' '- Djava.class.path=F:\\ sikuli\\ 1\ sikulixapi.jar') Screen = JClass (' org.sikuli.script.Screen') Key = JClass ('org.sikuli.script.Key') Pattern = JClass (' org.sikuli.script.Pattern') KeyModifier = JClass ('org.sikuli.script.KeyModifier') myscreen = Screen () mykey = Key () mykeymodifer = KeyModifier () myscreen.capture (0,0,1366 768) myscreen.click (Pattern ('minimize window .png') .similar (0.6) if not myscreen.exists ('add.png',2): print ("browser not detected The chrome browser will open automatically! ") Myscreen.doubleClick ('chrome.png') myscreen.click (Pattern (' add.png'). Similar) myscreen.type (url) myscreen.type (mykey.ENTER) myscreen.type (mykey.ENTER) myscreen.click (Pattern ('maximize .png'). Similar (0.6) myscreen.click (Pattern ('grab .png'). Similar (0.6) time.sleep (2) for i in range (5): myscreen.click (Pattern ('4) .png') .similar (0.6) myscreen.click ('taste.png') myscreen.click (Pattern (' shopping cart.png'). Similar (0. 6) shutdownJVM ()

‍ [knowledge points]

1. How does python call the jar package

Blogs that used to grab red envelopes are mainly based on sikuli IDE, that is, their own app software interface. But when I downloaded the sikuli program, I actually downloaded a sikuliapi.jar package.

So the question now is how to call the jar package with Python. Quite simply, you can use the jpype library or the jython library. This paper takes jpype as an example. (the current premise is that the local computer has installed java and successfully configured the java environment variable; if you do not know how to configure java or the students who install it, you can use your own Baidu)

(1) obtain jvm path information

(2) start Jvm and you can call the jar package you want.

2. Function usage of sikuli jar package

(1) screen: get the current screen, and then perform the operation of specific buttons. The corresponding functions include capture for determining the scope of the screen, and selectRegion () for manually determining the range of the detection screen.

(2) Pattern: used for image matching, supporting similarity similiar (0.7) and offset setting targetOffset (10Magazine 30). 0.7 means 70% similarity 10 means moving up 10 pixels, 30 means moving 30 pixels to the right

(3) Key: for keyboard input

(4) KeyModifier: used to obtain keyboard control objects, such as ctrl/alt/shift, etc., often used in combinations such as ctrl+A

Corresponding screen operation:

(1) Click myscreen.click

(2) double-click: myscreen.doubleClick

(3) input: myscreen.type

(4) corresponding enter input: mykey.ENTER

(5) ctrl+a combination input: myscreen ('axiomaginomy KeyModifier.CTRL)

The above content is how to realize the automatic order grabbing function of Taobao based on sikuli jar package in Python. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report