Exercise 2 Better solution : Python tutorial 221

preview_player
Показать описание
This is better solution for exercise 2
Рекомендации по теме
Комментарии
Автор

Hello sir!! Here May I use page.seek(second_quote) instead of page=page[second_quote: ] ?

joydip
Автор

We can also do as batter solution:
with open("file.html", "r") as html_file:
with open("output_file.txt", "a") as output_file:
for line in html_file.readlines():
position = line.find("<a href=")
for i in range(line.count("<a href=")):
firstquate_position = line.find('"', position)
secondquate_position = line.find('"', firstquate_position+1)
url =
# print(url)
output_file.write("==> "+url+"\n")
position = secondquate_position + 1
Note : This is 100% working try it

ladvamitesh
Автор

es series m aap hame numpy or pandas k bare m

shravanprajapati
Автор

we can also use count and a for loop for simplification in previous program!!!

samyakjain
Автор

Sir are you complete the writing of python book?

adarshadinda
Автор

please send the link of tutorial number 220

maabaapfirst
Автор

sir append ki jagah write mode me challo ans galat ara ha

mayanktiwari
Автор

nice video ! can you please upload the Source Code Link ?

ketanbhikadiya
Автор

Sir g, you are best. Love from Pakistan. I have a query. You have described in your playlist description GUI with Tkinter. I want to ask why not PyQt?

moqqaaofficial
Автор

How about this way?

import re

with open('./data.txt') as webpage:

urls = re.findall(r'(http[^"]+|www[^"]+)', webpage.read())

for u in urls:
print(u)

rahulon
Автор

I don't know why I don't understood this video.

techzwithsandesh
Автор

How to count video duration time in asp.net

Vanraj_Chudasama
Автор

and how to import numpy in visual studio code ?

shravanprajapati
Автор

More enhanced way


#program to extract n no. of links in one line links
target = r'B:\Python
extract = r'B:\Python

def url_finder(link):
if "href" in link:
comma_split = link.split('\"') # ' \" '
return [each for each in comma_split if each[-4: ].lower() == ".com" ]

def transfer(target, extract):
with open(target) as rf:
with open(extract, 'w') as wf:
for line in rf.readlines():
contain_url = url_finder(line)
if contain_url != None:
for extractedLink in contain_url:
wf.write(f"\n> {extractedLink}")
wf.close()
rf.close()

transfer(target, extract)

hamzaarain