NavpreetDevpuri/PEG

Handle according to response type from URL while downloading a file from chrome

Opened this issue · 5 comments

Improve the following function to handle different types of responses

PEG/peg/main.py

Lines 37 to 47 in dcd2f8a

def download_file_from_url_using_chrome(self,file_url):
open_chrome()
# We got to enter url section
pyautogui.hotkey('alt', 'd')
# paste the given file url so that we can download the file
pyautogui.write(file_url)
# let file load first then we download
pyautogui.hotkey('enter', interval=3)
pyautogui.hotkey('ctrl', 's', interval=1)
# if window is there then we have to press enter button to download file
pyautogui.hotkey('enter')

There are two types of responses when we request for file
0. file opens within chrome and we need to download it manually

  1. file starts downloading automatically

@NavpreetDevpuri I think pyautogui handles only keyboard ,mouse functions , so how do we handle this scenario ?

Good question, try to analyse response headers by using burp suite (by using proxy) and try to find what makes the difference.

And one more way to find out is

When url loads the loading icon disappears and file start downloading resulting into a small download bar at the bottom, we can somehow detect that bar. Its very similar way to how human detects.

@NavpreetDevpuri can we use pygetwindow library for detecting this download window ? pygetwindow comes in the pyautogui library.

We want our library to be used even when we don't having access to native code execution.

For example imagine a situation where our python code only able to see the screen by using TeamViewer or something, then our python code should understand the screen similar to an artificial intelligence.

For example imagine a situation an artificial intelligence robot wants to work with pc screen then that robot will be forced to use image recognition.

Yes we can have two different modes one will have host execution and one will be purely on visual recognition but for now we want our library totally on image recognition.

Using pygetwindow will leads to use host code execution so, we should avoid using it.