我想检索所有<p>
标签,然后在一个字符串中从中发送文字。
问题1 。在运行此代码时,它也会提供所有标记。
问题2 。如果我使用loop
打印con
,则会提供多个字符串。如果我将它再次附加在一个字符串中,那将是笨拙的。
那么,如何用短代码从下面的代码中获取文本?
import re
import urllib.request
from bs4 import BeautifulSoup
requ = urllib.request.Request("http://www.chowrangi.pk/10-reasons-gender-equality-not-exist.html", headers={'User-Agent': 'Chrome/51.0.2704.103'})
htmll = urllib.request.urlopen(requ).read()
soupi = BeautifulSoup(htmll,"html.parser")
Con= soupi.findAll("p")
print(Con)
# for con in soup.findAll("p"):
# print("Paragraph :" ,con.text)
答案 0 :(得分:0)
只需使用列表comp和str.join创建一个字符串:
soup = BeautifulSoup(html, "html.parser")
Con = "".join([p.text for p in soup.find_all("p")])
print(Con)
这给了你:
Women want equality, but they do not want to let go of their privileges. Women want freedom, but they do not want accountability. Women want to be liberated, but they do not want responsibility.Below are 15 reasons which shows how equality is only applicable when it works for women. Otherwise, women would be protesting against the following in order to achieve equality. It shows their hypocrisy and double standards. 1. Lifeboats are reserved for women.2. The media only focuses on women’s issues.3. World’s most dangerous jobs are worked by men.4. Seats are reserved for women on public transport.5. News channels announce deaths of ‘women’ and children.6. Juries discriminate against men in domestic violence disputes.7. Women have special quotas in the parliament, companies, and colleges.8. Women receive lighter sentences for the same crimes committed by men.9. Child custody is given to women is divorce courts, in the majority of cases.10. Men have to earn for women, but women are not under any obligation to earn for men.11. Domestic violence and dowry are seen as women’s issues, while men are the prime victims.12. Men give women child support and alimony, not the other way around. Men are ripped off their life savings.13. Men are used as ATMs. Women always marry men who are richer, earn more, ‘well-settled’, and better educated.14. Men die on jobs daily. 95% of work related deaths are of men, but that is neither an issue, not something that women and children are grateful for. 15. Draconian laws where women can land men behind bars with little evidence if any, giving a rise to false cases of dowry, rape, and domestic abuse. Police readily believe women, even though they lie more. Subscribe to our e-mail newsletter to receive updates.When blacks were forcrd to leave seats for whites, we called it slavery. When men are told to leave seats for women, we call it politeness! Why don’t women leave their seats for men?You need to add that women are released first in hostage situations, most teachers hired in schools are women, there is open discriminatory behaviour of teachers against boys in schools. men have to propose to women, women hitting men is socially acceptable, men make up the majority of homeless, war casualties, unemployed, suicides, compulsory conscription ….All the double standards are set by women.A man exposing in public = pervert
A woman exposing in public = liberatedMen seeking equal treatment = backlash
Women seeking equal treatment = feminismDiscrimination against men = equal opportunity
Discrimination against women = discriminationA woman with grievances = victim
A man with grievances = angryAny woman = victim
Any man = oppressorA woman talking about hating men = empowerment
A man talking about hating women = hate speechFemale genital mutilation = sexual repression
Male genital mutilation = acceptable customA man assaulting a women = violence
A woman assaulting a man = humorousA man who beats his female partner = batterer
A woman who beats her male partner = victimA disposable slave = man
A human being = womanHating women = a crime
Hating men = a viable political actAny power a man has = patriarchy
Any power a woman has = empowermentPornography pleasing to lesbians = erotica
Pornography pleasing to men = exploitation and degradation of womenPerson who say feminists are wrong = hate criminals
People who say men are wrong = feministsPatriarchy = bad
Matriarchy = goodMale leader = backwards
Female leader = improvementPro-lesbianism and female, anti-male = feminist ideology
Same standards, honest competition = unfairFemale virgin = pure
Male virgin = patheticFemale modesty = noble
Male modesty = creepyPandering to male audiences = sexism
Pandering to female audiences = fulfilling a nicheWomen standing up for themselves = empowerment
Men standing up for themselves = chauvinismWoman proud of her appearance = confident
Man proud of his appearance = vainInnate female advantages = complementary
Innate male advantages = sexistWomen’s space = safe haven
Men’s space = patriarchal breeding groundWomen discussing their issues = therapeutic
Men discussing their issues = whiningFemale intellect = pioneering
Male intellect = masturbatoryMan obeying a women = respect
Women obeying a man = slaveryMen being sexually critical = shallow
Women being sexually critical = having standardsFemale rage = man’s fault
Male rage = man’s faultMale abuse of power = direct consequence of patriarchy
Female abuse of power = indirect consequence of patriarchyUnemployed woman = homemaker
Unemployed man = loserFemale indulgence = success
Male indulgence = selfishnessComment Name (required) Email (will not be published) (required) Website
© 2016 Chowrangi. All Rights Reserved.