Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

html regex pattern does not work #1

Open
remcodejong1 opened this issue May 30, 2023 · 5 comments
Open

html regex pattern does not work #1

remcodejong1 opened this issue May 30, 2023 · 5 comments
Assignees
Labels
bug Something isn't working ready for test Test validation required

Comments

@remcodejong1
Copy link

Hi,
As we discussed earlier, the values are not extracted from the html email. Not even after you change your script.
As soon as I put the output of the email into a regex tester with the relevant patterns I don't get a match either. I have attached the output of the script with echo body.
I will also see if I can come up with a solution myself.

Output.txt

@Bram-diederik
Copy link
Owner

Its the euro sign. Will fix it

@Bram-diederik
Copy link
Owner

can you try again?

rewrote the html regex based on your output rather than the build in html parser of firefox.
they make up things.

@Bram-diederik Bram-diederik self-assigned this May 30, 2023
@Bram-diederik Bram-diederik added the bug Something isn't working label May 30, 2023
@remcodejong1
Copy link
Author

remcodejong1 commented May 30, 2023

Hi,
I have come to a solution myself in the meantime.
I used the first version of your script and code

    _// E-mailgegevens verwerken
    $header = imap_headerinfo($mailbox, $email);
    $subject = $header->subject;
    $fromAddress = $header->fromaddress;
    if (strpos($fromAddress,$from_email)) {

    $body = imap_body($mailbox, $email);
    $patternNormaaltarief = '/Totaal normaaltarief =E2=82=AC ([0-9,]+) =E2=82=AC ([0-9,]+)/';
    $patternDaltarief = '/Totaal daltarief =E2=82=AC ([0-9,]+) =E2=82=AC ([0-9,]+)/';
    $patternGastarief = '/Totaal =E2=82=AC ([0-9,]+) =E2=82=AC ([0-9,]+)/';_

Changed into

    _// E-mailgegevens verwerken
    $header = imap_headerinfo($mailbox, $email);
    $subject = $header->subject;
    $fromAddress = $header->fromaddress;
    if (strpos($fromAddress,$from_email)) {

	$body = imap_fetchbody($mailbox, $email, 1);
	$body = html_entity_decode($body);
	$body = strip_tags($body);
	
	
    $patternNormaaltarief = '#Totaal normaaltarief\s+€ (\d+,\d+)\s+€ (\d+,\d+)#';
    $patternDaltarief = '#Totaal daltarief\s+€ (\d+,\d+)\s+€ (\d+,\d+)#';
    $patternGastarief = '#Totaal\s+€ (\d+,\d+)\s+€ (\d+,\d+)#';_

Now it works for me!

@Bram-diederik
Copy link
Owner

well it works for you.

I keep this open until someone find it fixed.

now we both wait till Thursday to see if the price is updated

@Bram-diederik
Copy link
Owner

are you able to test my latest code with the html translation?

@Bram-diederik Bram-diederik added the ready for test Test validation required label Jun 1, 2023
@Bram-diederik Bram-diederik changed the title regex pattern does not work html regex pattern does not work Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready for test Test validation required
Projects
None yet
Development

No branches or pull requests

2 participants