Basically what I'm trying to do is the following:
I've downloaded an HTML file and within this file contains a load of text and loads of different email addresses. What I would like to do is to only gather the email addresses from this file and input into 1 excel file using Python 3.4. Would anybody be able to help with that?
The HTML file looks like this:
<span style="display: none;"></span>
</td>
<td>Customer Care
- <a href="?team_search=Team%20Resera" >Team Resera</a>
<br>(team page & map)
</td>
<td>Berlin (BER2): Sesamestreet 11-12 </td>
<td>blablabla.blabla#blabla.com<br />
(jabber)
(xmpp)
</td>
<td>
work: 72496532 (Skype)<br />
</td>
This should get you started, from the example html it outputs
import re
file = open('example.html')
line = file.readline()
while line:
line = file.readline()
if bool(re.search(r'([\w.])+#([\w.])+', line)):
email = line.split('//',1)[-1]
email = email.split('\"',1)[0]
print email
file.close()
#outputs blablabla.blabla#blabla.com
Related
I'm new to html ,i need to add tags inside the table row but whenever i add tags it doesn't print values only empty fields are shown .here is sample value added in between .The row data is only tags.Can anyone help me with this
<td>
<parents>
<proc pid="19344" parentPid="7084" path="C:\Program Files (x86)\COMODO\Comodo ITSM\RmmService.exe" cmdline=""C:\Program Files (x86)\COMODO\Comodo ITSM\RmmService.exe"
--run_procedure
--in Global\sharedInputMemory_124
--out Global\sharedOutputMemory_125
--err Global\sharedErrorMemory_126" name="RmmService.exe" interpreter="false" sha1="0F3F5B4F23C03FC4BA72BE38A6E44DCD6EEB13C9" />
<proc pid="7084" parentPid="1332" path="C:\Program Files (x86)\COMODO\Comodo ITSM\RmmService.exe" cmdline=""C:\Program Files (x86)\COMODO\Comodo ITSM\RmmService.exe"" name="RmmService.exe" interpreter="false" sha1="0F3F5B4F23C03FC4BA72BE38A6E44DCD6EEB13C9" />
<proc pid="1332" parentPid="1252" path="C:\Windows\System32\services.exe" cmdline="" name="services.exe" interpreter="false" sha1="D7A213F3CFEE2A8A191769EB33847953BE51DE54" />
<proc pid="1252" parentPid="0" path="C:\Windows\System32\wininit.exe" cmdline="" name="wininit.exe" interpreter="false" sha1="96B04445102445682879C8F21E38A93A30E8F3FD" />
</parents>
</td>
I created a function and set a get method to receive all the data from my table.
However I can't display images on browser. I have tried all the "solutions" but nothing seems to work.
This is what I currently have
<tbody>
<tr *ngFor="let obj of dataArr">
<td>{{obj.name}}</td>
<td>{{obj.price}}</td>
<td>
<img src="data:image/png;base64,{{obj.img}}"/>
</td>
</tr>
</tbody>
Name and price are displayed fine.
This is the data that I receive when I console log:
0: {id: 2, name: "nesto", price: "6", img: "ÿØÿàJFIFÿáExifII*ÿá…"QD¢%(DJ"QD¢%(DJ"QD¢%(DJ"QD¢/ÿÙ"}
Probably you're looking for this:
<img src="data:image/png;base64,{{
btoa(obj.img) /* or window.btoa(obj.img) try both */
}}"/>
I advise you to create a route which retrieves the file from database:
// routes.php
Route::get('files/{record_id}', function($record_id){
$Model = \EloquentModel::firstOrFail($record_id, ['img']);
return response($Model->img)->header('Content-Type', 'image/png');
});
// angular file
<img src="/files/{{ obj.id }}">
I am stuck with this issue in Django: I want to download a file already existing on my server through a html form. The file to be downloaded is served through a function in views. My problem is with html form and passing the file name to view. How can I pass the name of the file from form toward view without having to select the file?
In html I have:
# 'content' keeps the name of the file to be downloaded
{% block content %}
{{content}}
<table>
<tr>
<td>
<form action="" method="POST" enctype="multipart/form-data">
<input type="file" name="file"/>
<br />
<input type="submit" value="Download File" />
</form>
</td>
</tr>
</table>
{% endblock %}
When I select the file and press submit button, it works but I need a different behavior: the name of the file containing results (downloadable file) to be passed to views into a variable. The views will then serve it.
The view which handled the downloadable file:
def forecast(request):
if request.method == 'POST':
#handle_download_file(request.FILES['file'], str(request.FILES['file']))
print('request.method este: ',request.method)
RESULTS_filename = 'frcst_'+ str(request.FILES['file'])
#download('GET', RESULTS_filename)
file_path = os.path.join(os.path.relpath('forecast/'), RESULTS_filename)
print (file_path)
print(settings.MEDIA_ROOT)
with open(file_path,'rb') as fh:
response = HttpResponse(fh.read(), content_type="application/vnd.ms-excel")
response['content-disposition'] = 'attachment; filename='+RESULTS_filename
print(response)
return response
HttpResponseRedirect('/forecast/')
return render(request,'result_links.html',{'content':'frcst_history.csv'})
I am making a website of my shop items, where I need to daily update the items which includes item_name, brand_name, price, item_no., etc. Writing html codes daily is becoming very hard work for me. So, I want to make changes about the items in a CSV file, and import the data into my website. How to do that, Please help me. Thank you in advance. Here is some sample codes:
read_data.html
<html>
<head><title>Reading values from csv file</title></head>
<style type="text/css">
div{
width: 300px;
}
img{
height: 200px;
}
</style>
<body>
<div>
<img src="#" alt="item 1"><br>
Item Name:<!--CSV file data--><br>
Item Number:<!--CSV file data--><br>
Brand Name:<!--CSV file data-->
</div>
<div>
<img src="#" alt="item 2"><br>
Item Name:<!--CSV file data--><br>
Item Number:<!--CSV file data--><br>
Brand Name:<!--CSV file data-->
</div>
</body>
</html>
data.csv
Item Name,Item no.,Brand
T-shirt,555,Hoffmen
Pants,556,Reliance
Edit: this is assuming you have a way to store the data (e.g. a database). It sounds like you would benefit from a CMS (e.g. Wordpress). Anyway, this answer addresses the question of how to get the CSV data:
You can use Papa parse. It would look something like this:
// from file upload field
var file = event.target.inputCSV.value;
var data = Papa.parse(file, {header: true, skipEmptyLines: true, delimiter: ','});
return data;
// outputs something like [{Item_Name: "T-shirt", Item_no: 555, Brand: "Hoffman"}, {Item_Name: "Pants", Item_no: 556, Brand: "Reliance"}]
As suggested by Saptarshi, you'll probably need a database for this, where you can possibly import your CSV. This will help your handling and automize it. The solution might be based on a php/mySQL basis, for example. I'd do some research on the specialties and power of these languages first.
Hey most of my issue has been solved but i have little problem
This is Html
<tr>
<td class="ttl">
</td>
<td class="nfo">- MP4/H.263/H.264/WMV player<br />
- MP3/WAV/еAAC+/WMA player<br />
- Photo editor<br />
- Organizer<br />
- Voice command/dial<br />
- Flash Lite 3.0<br />
- T9</td>
</tr>
Currently i am using this code provided by Stackoverflow User
var text1 = htmlDoc.DocumentNode.SelectNodes("//td[#class='nfo']")[1].InnerHtml;
textBox1.Text = text1;
know problem its is getting all text
with <br>
how i can remove <br> from it and put , between them
its should look like this
MP4/H.263/H.264/WMV player,- MP3/WAV/еAAC+/WMA player,- Photo editor,- Organizer,- Voice command/dial,- Flash Lite 3.0,- T9
Also how to get this
<div id="ttl" class="brand">
<h1>Nokia C5-03</h1>
<p><img src="http://img.gsmarena.com/vv/logos/lg_nokia.gif" alt="Nokia" /></p>
</div>
i am trying this
var text41 =
htmlDoc.DocumentNode.SelectNodes("//div
id[#class='brand']")[0].InnerText;
i get invalid token error
i only want C5-03 without nokia text
You can simply use a string.Replace("<br />", ""); to remove the <br /> tags.
Better yet, use the InnerText instead of InnerHtml, so no HTML comes through:
var text1 = htmlDoc.DocumentNode.SelectNodes("//td[#class='nfo']")[1].InnerText;
If you really want to replace all <br /> tags with a , you will indeed need to use Replace:
text1.Replace("<br />", ",");
To select the value in the <H1> tag, you could use:
var text42 = htmlDoc.DocumentNode.SelectNodes("//div[id='ttl']"/h1)[0].InnerText;