parsing - How do I build an array of names gathered from a text file which correspond to an array of links gathered from the same file? -
i need create array of names correspond links images have stored in array. both names , links images found in same text file, , links images follow corresponding names in file. build array of image links parsing text file using following code:
import re images = [] open('html_test.txt') f: line in f: images.extend(re.findall(r'"([^"]*\.(?:jpg|gif)[^"]*)"',line))
using similar method build list of names, if there 1 name per image link. unfortunately number of image links following each name variable, names followed 1 image link, followed many.
what think need count how many links images follow each name, create duplicate entries in name array each name followed more 1 image. (the number of duplicate name entries per name equal number of image links follow each name minus 1.) when try however, count of total number of names in entire text file. know how go building array of names each name entered array once each link image file follows it? (except follow next name in text file)
below example of text file looks like:
<a href="/admin/user/view/41900" title="example_name_1" rel="41900"> <div class="thumb"><a href="#"><img src="https://jibbertyjob.com/asset/image/resize/2/32/32/1/5d4e6a0fjfe94980ny8en9uf98frnoad1876c00.jpg" width="32" height="32" alt="" /></a></div> <a href="/admin/user/view/41900" title="example_name_2" rel="41900"> <div class="thumb"><a href="#"><img src="https://jibbertyjob.com/asset/image/resize/2/32/32/1/5d4e6a0fjfe9dfgsdfg9uf98frnoad1876l00.jpg" width="32" height="32" alt="" /></a></div> <div class="thumb"><a href="#"><img src="https://jibbertyjob.com/asset/image/resize/2/32/32/1/5d4e6a0fjf4567w034098h9h5fg4gr33r3rggr376c09940.jpg" width="32" height="32" alt="" /></a></div>
thanks i've been stuck on half of day!
Comments
Post a Comment