0

I have tried to use this:

c=requests.get('https://www.uniberg.com/referenzen.html').text
c.count('Programmierung')

But the output shows 2 occurances while there are actually none.

Also I tried this:

a=requests.get('https://www.uniberg.com/index.html').text.count('Mitarbeiter')

but it also returns the count of words like Mitarbeiterphilosophie which I don't want. Can someone find a way to improve this or suggest another method?

4
  • <p class="detail">Design und Architektur einer OpenStack-Umgebung zur Integration einer virtualisierten IMS Open Source Lösung. Aufbau, Integration und Installation. Programmierung und Automatisierung der funktionalen Erweiterungen zur Integration in die Rechenzentrums-Infrastruktur insbesondere hinsichtlich Deployment und Skalierung.</p> Commented Jun 26, 2018 at 6:35
  • What made you think there are no occurrences? Commented Jun 26, 2018 at 6:35
  • Use NLTK to find the count reddit.com/r/pythontips/comments/4mu9qq/… Commented Jun 26, 2018 at 6:39
  • Possible duplicate of item frequency count in python Commented Jun 26, 2018 at 7:57

2 Answers 2

1

Today https://www.uniberg.com/referenzen.html contanins 2 occurances Programmierung

I think, you need check in HTML source code, not in the render using a browser.

The words Programmierung are on HTML section with this CSS

section .detail {
    display: none;
}

For the second point :

try this (using regex) :

import re
len(re.findall(r'\WMitarbeiter\W', requests.get('https://www.uniberg.com/index.html').text))

With regex :

  • \w stands for "word character", usually [A-Za-z0-9_].
  • \W is short for [^\w], the negated version of \w.
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks this worked for the second point, still looking for a solution to the first
0

requests.get(URL) returns the entire Web-page(look at it with ctrl+U on Google-Chrome or just use wget to download the webpage) and not just what is rendered by web browser.That's why count is showing up as 2.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.