This is a follow up question from here
Using Racialz answer i can loop everything using the regex but only the last line of data is stored in the database how do i store all of the data instead of only the last 1
for thisMatch in re.findall(r"<td>(.+?)</td>.+?<td>(.+?)</td>.+?<td>(.+?)</td>.+?<td>(.+?)</td>", match3, re.DOTALL):
print(thisMatch[0], thisMatch[1], thisMatch[2])
sinfo = scrapyitem(name=thisMatch[0], hp=thisMatch[1], email=thisMatch[2])
try:
sinfo().save
EDIT
match2 and match are just regex to narrow down on the search data.( i know it might be redundant and some might ask me to use parser instead )
my_string = str(i)
match = re.search("\<!-- populate table from mysql database -->(.*?)\ /tbody>" , my_string).group(1)
match2 = re.findall('\<div class = "info">(.*?)</tr>' , match)
match3 = str(match2)
data:
<div class = "info">
<div class="name"><td>random</td></div>
<div class="hp"><td>123456</td></div>
<div class="email"><td>random@mail.com</td></div>
</div>
<div class = "info">
<div class="name"><td>random123</td></div>
<div class="hp"><td>654321</td></div>
<div class="email"><td>random123@mail.com</td></div>
</div>
The info saved into database will only be :
random123
654321
random123@mail.com
match3 gives me:
<div class="name"><td>random</td></div>
<div class="hp"><td>123456</td></div>
<div class="email"><td>random@mail.com</td></div>
<div class="name"><td>random123</td></div>
<div class="hp"><td>654321</td></div>
<div class="email"><td>random123@mail.com</td></div>