本帖最後由 epcsub 於 2023-11-1 23:46 編輯
如果有固定workflow 用python嘅Class chain methods去執行比較清楚
例如我有兩個workflow- Work().datatxt('abc_data.txt').load_webpage('https://xxx.com/abc.html').template('abc_map.txt').feed()
- Work().dataxls('xyz_data.xls').load_webpage('https://xxx.com/xyz.html').template('xyz_map.txt').feed()
複製代碼 Work => python class having some methods:
datatxt() => read a text file, parse the data therein into list/tuple
dataxls() => read an excel file, parse the data therein into list/tuple
load_webpage() => load a webpage into a selenium object (perhaps)
template() => define a template, to define the location (target tag,id,class) of each piece of data into a dictionary (maybe)
feed() => based on the template, feed the data into defined locations
你提供不同data_file, template_file 可以應付不同嘅webpage
format 得好睇啲可以- x=(
- Work()
- .datatxt('abc_data.txt')
- .load_webpage('https://xxx.com/abc.html')
- .template('abc_map.txt')
- .feed()
- )
複製代碼 甚至把兩個workflow chain做一條龍- x=(
- Work()
- .datatxt('abc_data.txt')
- .load_webpage('https://xxx.com/abc.html')
- .template('abc_map.txt')
- .feed()
- .dataxls('xyz_data.xls')
- .load_webpage('https://xxx.com/xyz.html')
- .template('xyz_map.txt')
- .feed()
- )
複製代碼 |