Skip to content

Commit

Permalink
fix edupage scrape errors
Browse files Browse the repository at this point in the history
  • Loading branch information
divear committed Jul 11, 2024
1 parent a40438c commit fbbc475
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 29 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ For some reason edupage doesn't have this build in, so I made this small script

## How do I use this?

1. Clone this repo, create a `.env` file in root directory and add:
1. Clone this repo, create a `.env` file in root directory and add your EduPage credentials:

```env
USERNAME=your_username
Expand Down
21 changes: 0 additions & 21 deletions rust.yml

This file was deleted.

32 changes: 25 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub fn main() -> Result<(), Box<dyn Error>> {
let browser = Browser::default()?;
let tab = browser.new_tab()?;

dotenv().expect(".env file not found");
dotenv().expect(".env file not found - follow instructions in the README");
let username = env::var("USERNAME").expect("USERNAME environment variable not set");
let password = env::var("PASSWORD").expect("PASSWORD environment variable not set");

Expand All @@ -49,10 +49,28 @@ pub fn main() -> Result<(), Box<dyn Error>> {

println!("znamky page");
tab.navigate_to("https://sspbrno.edupage.org/znamky/?eqa=d2hhdD1zdHVkZW50dmlld2VyJnBvaGxhZD1wb2RsYURhdHVtdSZ6bmFta3lfeWVhcmlkPTIwMjMmem5hbWt5X3llYXJpZF9ucz0xJm5hZG9iZG9iaWU9UDImcm9rb2Jkb2JpZT0yMDIzJTNBJTNBUDImZG9ScT0xJndoYXQ9c3R1ZGVudHZpZXdlciZ1cGRhdGVMYXN0Vmlldz0w")?;
tab.wait_for_element_with_custom_timeout(
"#edubarStartButton",
Duration::from_secs(WAIT_LIMIT),
)?;

loop {
match tab.wait_for_element_with_custom_timeout(
"#edubarStartButton",
Duration::from_secs(WAIT_LIMIT),
) {
Ok(d) => {
Some(d);
break;
}
Err(_) => {
println!("could not find, trying again");
}
};
}

// match is_loaded {
// Ok(is_loaded) => println!("works, {:?} is loaded", is_loaded),
// Err(_) => {
// println!("failed111")
// }
// }
let jpeg_data =
tab.capture_screenshot(Page::CaptureScreenshotFormatOption::Png, None, None, true)?;
// Save the screenshot to disc
Expand Down Expand Up @@ -87,8 +105,8 @@ pub fn main() -> Result<(), Box<dyn Error>> {
if new_znamka.chars().nth_back(0) == Some('%') {
let extracted_znamka = process_percent(&new_znamka);
if extracted_znamka.is_some() {
// znamky_all
// .push(extracted_znamka.expect("adding a working grade failed"))
znamky_all
.push(extracted_znamka.expect("adding a working grade failed"))
}
} else {
let extracted_znamka = match new_znamka.len() {
Expand Down

0 comments on commit fbbc475

Please sign in to comment.