影视指定台词截图的批量查找
1、那些富有感情的影视台词截图都是哪来的?
泰坦尼克号里面说过几次LOVE?
当我们祝福生日快乐的时候,仅仅是生日快乐显得干瘪,找来的表情包生硬诙谐,可是配合我们共同看过的影视,发过去影视截图,电影里面充沛的感情能在一张图片里表达的淋漓尽致,可我们又能收集到多少影视截图呢,我们日常看电影的时候又怎么会留心这种东西呢?Python大法好啊!
##2、 思路设计
如果想要获取到电影台词,语音识别不要想,肯定是靠字幕文件的搜索统计来获得。那么程序的目标就是
- 爬取字幕文件
- 搜索分析统计字幕文件
- 保存结果
在这里需要有一个小常识就是,字幕文件的格式应该是包含电影台词出现时间和电影台词的,我们需要记录时间和相应的台词。
我们暂定目标为 寻找泰坦尼克号,里面所有带love的台词和时间。
3、爬虫
经过许多字幕网站测试,那些长得越简单的字幕网站,下载链接摆的越明显的网站,越难爬取,封装headers、cookies都没法简单获取字幕的下载链接(http://www.zimuku.la 网站的下载地址谁会分析,或者想一起探讨爬虫技术,可以加作者我微信好友,微信号15600820866)。
见过一些测试我找到了 射手网(伪) – assrt.net ,不用换ip,不用cookies,简单封装headers伪装浏览器即可。我思考如何爬取那个很难的字幕网站,浪费了两天时间,还没有头绪。测试好几个字幕网站,找到一个爬取简单的网站,只用了一小时。还真是方向比努力更加重要,在达成目标的途径上,要灵活多变,思考寻找。
这里我们的目标是泰坦尼克号,我们人工搜索到泰坦尼克号的页面:
url = "https://assrt.net/xml/sub/610/610293.xml"
我们从这个地址开始,寻找这个电影里面所有的love(至于全网上百万影视所有的love,自己外面套个循环就好)
分析页面结构和内容,我们得到本模块需要的步骤。
- 获取该页面网页源码,绕过反爬
- 获取下载地址
- 保存文件(是一个压缩包,内含多个字幕文件)
#封装头部
headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36'}
#获取网页源码
req = requests.get(url, headers=headers)
#正则匹配,并且子串直接获取下载地址
ans = re.search(u"(/download/.*?)\"", str(req.content, 'utf8'))
download_url = "https://assrt.net" + ans.group(1)
#下载内含字幕文件的zip文件到桌面
data = requests.get(download_url, headers=headers)
adr = "C:\\Users\\XU\\Desktop\\" + str( download_url[download_url.rfind('/')+1:] )
with open(adr,"wb") as code:
code.write(data.content)
4、解压
网站部分提供的是zip文件,不都是直接可以打开的ass,art文件,我们做一个判断,如果是zip那我们就用模块直接给他解压了,没什么难度,Python真好用
#解压文件
def unzip(adr):
#后缀判断
if(adr[-3:]=='zip'):
f = zipfile.ZipFile(adr, 'r')
os.chdir("C:\\Users\\XU\\Desktop")
#解压所有文件
for file in f.namelist():
f.extract(file,"temp/")
f.close()
fileList = os.listdir( "C:\\Users\\XU\\Desktop\\temp")
os.chdir("C:\\Users\\XU\\Desktop\\temp")
#返回文件列表,便于多个文件搜索
return fileList
else:
os.chdir("C:\\Users\\XU\\Desktop\\")
return [adr,]
5、字幕文件的格式
无非就是 时间 颜色字体大小等信息 字幕文本
一眼看穿,按行读取,匹配出时间和字幕就成。
6、提取并搜索
参数是待查找的字幕文件和我们要找的台词
def search(fileList,msg):
#结果保存进list
ans = []
#循环每个文件
for file in fileList:
with open(file, encoding='utf8', errors='ignore') as file_obj:
for line in file_obj.readlines():
#找英语的话,全部小写处理
line = line.lower()
#如果找到了,就保存
if line.find(msg)!= -1:
#保存的格式是时间+当前台词
ans.append(last_line+line+'\n') #information
#上一行的时间直接保存在last_line里,具体格式要熟读字幕文件的格式才能看懂哦
last_line = line
#多个字幕文件,其中内容相同,但是语言不一样,只要找到了一个,说明不用继续找下去了
if len(ans)!=0:
break
return ans
7、保存搜索结果
def write_down(ans):
with open('ans.txt','w') as f:
f.writelines(ans)
f.close()
print("查找到"+str(len(ans))+'句话,已保存至ans')
泰坦尼克号里面说过几次LOVE,在什么时间?
02:49:56,480 –> 02:49:58,150
i love you, jack.
8、小结
当我们知道了指定字幕发生的时间,我们也就能很简单的截图保存了。
本来海量的工作,在Python的帮助之下解决了,当然也不是简单的Python。路上我们要找到好爬取的网站,我们要解析字幕文件的格式,我们要提前想到我们想要的台词数据藏在字幕文件里面,字幕文件为了定位,必须有时间标签。
Python不是万能的,当你有一万种使用它的思想,它才是万能的;如何让好的工具更加大放异彩,是我们需要经历和思考的。
本文首发于公众号:小詹学Python,未经许可不得转载!扫码回复「截图」获取代码
那些富有感情的影视台词截图都是哪来的?
akqtcjirext
[url=http://www.gfrw29q5xs27l68st77qk8k9w7ty3280s.org/]ukqtcjirext[/url]
kqtcjirext http://www.gfrw29q5xs27l68st77qk8k9w7ty3280s.org/
Featured
7ml glass vial
Disposable Mask Coles
18/ 410 Treatment Pump
Desktop Fiber Laser Marking Machine
100w Co2 Laser Engraving/cutter
Best mask factory
China Kid Shoes and Kids Shoes Children price
Animal Feed Premix
Aluminium Extrusion Dies
China Wholesale Foldable Moving Cart Factory
Lock Device Factory
In addition to fluid retention, the hormone relaxin, released primarily
during the third trimester to relax your pelvic ligaments for childbirth,
flattens and lengthens foot ligaments. how much viagra should i take the first time?
Viagra before and after
Dry Air Blower
44083-61000 Hydraulic Gear Pump
Fiber Bulk
Symptoms of meniscal injury may sometimes disappear on their own, but
frequently persist or return months or years later and require treatment, particularly if the knee is injured a
second time. online pharmacy usa viagra, http://llviabest.com/, generic viagra online no prescription
ReplyApple cider vinegar alive and unpasteurized, with the mother morning and evening would probably be a good topical treatment for you.
how to get viagra online buy real
viagra online cheap
Vertical Suction Pump
Nylon PA6 Rod Supplier
日本AV性爱电影
Cut Glass Whisky Tumblers Supplier
farmacia svizzera viagra https://buybuyviamen.com/ viagra recommended use
best price viagra generic viagra canada viagra and celexa
viagra online https://wowviaprice.com cheap generic viagra online australia
viagra distintas marcas purevigra.com viagra kaufen in hannover
eccesso viagra viagra estados unidos viagra china en venezuela
C Shaped Steel Presser
Apparel Testing
paypal viagra viagra brand man on viagra
viagra brand paradiseviagira.com buy viagra online australia no prescription
Sildenafil cost 100mg https://miraclevigra.com/ average price
of sildenafil in usa 100mg
hur vanligt Г¤r viagra quanto custa o viagra no brasil hotmail viagra spam
Buy viagra online in india https://lightvigra.com/ viagra 100 coupon
Price of sildenafil tablets hopeviagrin.com generic
viagra no prescription
Viagra online india pharmacy https://mygoviagar.com viagra 15 mg
Bulk Feed Bin
Egg Tray Machine India
Alu Foil With Scrim With Kraft Paper
can i buy viagra over the counter in mexico buy viagra online rx where can i get sildenafil
internetapotheke Г¶sterreich viagra aspirine coca effet viagra can you come on viagra
where to buy sildenafil usa viagra 800mg price generic viagra online uk
buy viagra mastercard accepted viagra dapoxetine canada viagra 50mg 100mg
viagra pills discount generic viagra for daily use get a viagra prescription online
is viagra dangerous for young people how can you make viagra more effective can 20 years old take viagra
viagra online australia paypal order viagra from canada viagra substitutes over the counter
essays describing yourself do my homework for money unit 731 research paper
Hour Meter
0 – Organic Resveratrol Bulk Powder
homework help mummies buy research paper with mla citations college essay prepscholar
college essays google docs method of writing an essay essay on help
guidelines for writing a reflective essay paper write speech about myself assignment help australia
Buying essays online https://buyessayhelpbtg.com/
buy college essay
essays on work money essay writing citing a website in essay
I don’t want to write my paper https://writemypaperbuyhrd.com write my apa paper
Thesis writing service https://thesiswritinghelpsjj.com dissertation thesis
writing
argumentation and persuasion essay marketing dissertations buy homework assignments cheap
Electrical Distribution Box
Outside Table And Chairs
cheapest cialis tadalafil 20 mg buy cialis genaric cialis with dapoxetine
buy cialis with paypal cialis inr how to buy cialis from us stores
viagracialisevit wham 1180 viagra generic viagra and paypal
Pharmacy tadafcialirx.com tadalafil cheap
Daily cialis gocialirx.com cialis dose
on line viagra buy viagra london ontario viagra on line
order cialis uk brandcialis cialis without prescripe
Where to buy viagra https://atviagrmenrx.com/ viagra over
the counter walmart
generic cialis cost best price for cialis 20 mg cialis coupon code
paypal viagra no prescription viagra free sample ordering viagra gold online
viagra 100mg 30 pills 800mg viagra gold how to buy viagra online without
Wow that was unusual. I just wrote an very long comment but after I clicked submit
my comment didn’t show up. Grrrr… well I’m not writing all that over again. Anyway, just wanted to
say wonderful blog!
My homepage – porn
viagra kamagra viagra ou acheter du viagra en pharmacie sans ordonnance
ou acheter du viagra site fiable
visual viagra viagra pharmacie le viagra est il rembourse
comment faire du viagra naturel a la maison
generico cialis générique cialis que choisir viagra cialis levitra
cialis ou viagra?
viagra 50mg tablets viagra shoppers drug mart where to buy generic viagra
cialis fiyatları prix cialis comment prendre cialis 20 mg
cialis sur ordonnance ou pas
Hi there colleagues, its great post on the topic of teachingand fully explained, keep it up all the time.
Feel free to surf to my web site … sex
levitra 20mg preise levitra levitra costo mexico
levitra 20 milligram
I all the time used to read post in news papers but now as
I am a user of net therefore from now I am using net for posts,
thanks to web.
my blog post … xxx (http://winnersoft.com.ua/bitrix/rk.php?goto=https://anyxxx.com/search/smallest-pussy-ever/)
dci viagra viagra online france ou trouver du viagra en italie
aliment qui remplace le viagra
cialis feminin cialis vs viagra cialis prise en charge securite sociale
ou se procurer du cialis sans ordonnance
viagra kostenlos probe viagra holland was kostet viagra in holland
was ist besser viagra oder kamagra
modafinil and cocaine generic modafinil modafinil smart drug buy
what is an overdose of modafinil
online pharmacy no prescription best drugstore foundation for dry skin cheap rx
mens ed pills rx ed
pharmacy cheap canadian pharmacy rx pharmacy coupons
erectile dysfunction causes pharma the peoples pharmacy
us pharmacy best drugstore primer best drugstore concealer
canadian pharmacy cialis rx express pharmacy people’s pharmacy
rx pharmacy online pharmacies indian pharmacy
cheap australian viagra buy kamagra is it illegal to order viagra online
how to get a cialis prescription online
viagra free viagra homme viagra générique sans ordonnance en ligne
combien vaut le viagra
levitra shop uk order levitra levitra vs cialis side effects
what is effecct of mixing viagra and levitra
modafinil alcohol interaction modafinil generic name provigil financial assistance program
how long does modafinil last?
cialis ausprobieren cialis frei verkäuflich holland cialis kaufen mit rezept
wann gibt es cialis als generika
Tinder dating site app ,
tider
why tulane essay college application essay how to write a rhetorical analysis essay
why uchicago essay examples
xxx stepmom viagra viagra kopen rotterdam kun je viagra zomaar kopen
wat is verschil tussen viagra en kamagra
viagra flytande form köpa viagra receptfritt hur fungerar viagra på kvinnor
var kan jag köpa viagra
local free dating site dating websites
canadian pharmacies-24h mail order pharmacy canada drugs online pharmacy
online rx pharmacy prescription drug price comparison cheap drugs
viagra super force without a prescription australia online pharmacy no prescription viagra buy viagra gold
ivermectin pill ivermectin buy where can i buy ivermectin for scabies
why such price differences in ivermectin pour on
the cheapest online viagra buy viagra in canada buy viagra online australia
erection pills viagra replacement canadian pharmacy reviews
cialis on ebay cialis tablets for sale safest place to buy cialis online
how long does it take for viagra to work?
men’s health international drug mart canadian pharmacy online store canadian pharcharmy online no precipitation
female viagra pill can i buy viagra over the counter in australia long term effects of cialis
how does cialis daily work
cialis 36 hour online buy cialis and receive in 48 hrs cialis
rapid cash title loans portland or ace cash express loan policy can i be arrested for not paying a payday loan in texas
united cash loans good reviews fast cash loans no phone calls payday loans in evergreen al
cialis vs viagra viagra pil bloedverduner mag ik dan ook viagra gebruiken
wat gebeurt er als je viagra slikt
viagra cheap cheapest viagra patent expiration date viagra no prescription australia
China Cotton Diaper
cialis eyaculaciГіn precoz viagra cialis levitra comparacion precios diferencias entre viagra cialis y levitra
farmacias en madrid que venden cialis sin receta
payday advance corona ca instant cash loans for newstart cash advance loan chart
赌厅网投
Pickled Yellow Onions
cialis medicine sildenafil vs cialis what is the generic for cialis
viagra or cialis which is better
Little Girls Swimsuit
viagra sample where to buy viagra connect usa viagra for women side effects
how much does viagra cost at walmart?
buy cialis 36 hour buy cialis canada cialis us pharmacy
Lid Glass Factory
欧美牲交AⅤ
write a comparison essay service professional resume writing service
Industrial Liquid Pumps
how to write a conclusion for a research paper examples pay someone to write my research paper fiverr
Industrial Control
澳门博狗
how to motivate yourself to write an essay write my essay online reviews
p71zc rjafs xmhy
Atm Kiosk Machine Metal Keyboard
Household Aluminum Foil For Food Packaging
help poor people essay help writing a essay
vujgf xtvsi s1c4
Gold Detection Handhold Metal Detector
essay porter, m. e. (1996). what is strategy?. harvard business review, 74(6), 61-78. how to write an essay about business ethics
business management essay example essay about ethics in business
Capacity Voltage Transformer Supplier
tadalafil max dose: http://tadalafilonline20.com/ what is tadalafil
China Ampoule Bottle Labeling Machine
generic tadalafil tadalafil gel
tadalafil max dose
cialis professional $200 cialis coupon
cheapest cialis web prices
prescription drugs without a doctor generic pills
sildenafil without doctor prescription: https://genericwdp.com/ best online international pharmacies india
generic drugs without doctor’s prescription: https://genericwdp.com/ generic pills
generic drugs without doctor’s prescription: https://genericwdp.com/ meds online without doctor prescription
Lvt Plank Flooring Installation
viagra online usa how much is viagra
online doctor prescription for viagra
vidalista
viagra amazon when will viagra be generic
online doctor prescription for viagra
ivermectin gel stromectol online canada ivermectin for chickens for sale how much ivermectin per pound for dogs
price of viagra п»їviagra pills
buying viagra online
buy viagra online usa how much is viagra
buying viagra online
п»їviagra pills over the counter viagra
buy real viagra online
Commercial Swimming Pool Design
best place to buy generic viagra online viagra from canada
order viagra online
viagra from india viagra cost
over the counter viagra
100mg viagra buy generic 100mg viagra online
п»їviagra pills
glaxosmithkline ventolin albuterol 0.043 ventolin hfa vs proventil hfa how is albuterol supplied
price of viagra buy generic 100mg viagra online
buy generic 100mg viagra online
metronidazole and ivermectin stromectol 0.5 mg can you use ivermectin for goats how to administer ivermectin to wild squirrels
buy generic 100mg viagra online п»їviagra pills
viagra from canada
amoxicillin chewable augmentin without prescription can you have alcohol with amoxicillin how long should i take amoxicillin for tooth infection
dulera vs ventolin albuterol otc australia where can i buy ventolin hfa how to get a free albuterol inhaler
Doll Real
where can i buy viagra over the counter best over the counter viagra
buy viagra online usa
buy paxil paxil cr generic
discount prescription drugs
http://propeciafavdr.com/ – finasteride without prescription
ambien without a doctor’s prescription
amoxicillin 500 buy amoxicillin over the counter uk can a child overdose on amoxicillin what can amoxicillin cure
lasix package insert cheap lasix 40 mg 40 mg lasix side effects what if lasix doesn’t work
zithromax price south africa zithromax cost uk
natural cure for ed
http://zithazi.com/ – zithromax buy
buying ed pills online
spironolactone vs lasix buy lasix 100mg hydrochlorothiazide 25 mg vs furosemide 40 mg what is lasix 20 mg used for
cheap viagra online https://viagrapills100.com/ best place to buy viagra online
viagra from canada https://viagrapills100.com/ when will viagra be generic
zithromax dose chlamydia where can i get azithromycin does azithromycin have sulfa in it how long does it take azithromycin to work
buy generic 100mg viagra online https://viagrapills100.com/ viagra without a doctor prescription usa
farmacia vistabella http://essinreceta.com/# precio de la viagra en farmacias
does doxycycline expire buy doxycycline united states doxycycline for cats side effects how long after taking doxycycline can i take amoxicillin
clomid amazon buy 10 clomid pills clomid 50mg days 5-9 how do i take clomid
alprostadil gel https://alprostadildrugs.com/ what is alprostadil
prednisolone reviews prednisolone how is prednisone converted to prednisolone how much does prednisolone cost
doxycycline and benadryl doxycycline 100 mg cap over the counter what infections does doxycycline treat? where can i get a prescription for doxycycline
generic tadalafil online – tadalafilo presentaciones tadalafil pill
vardenafil vs tadalafil which is better? https://vegavardenafil.com/ generic levitra vardenafil 20mg
liquid clomid where to get clomid success rates of iui with clomid how to use clomid effectively
order ed pills cheap ed pills
ed pills without a doctor prescription
cheap ed pills from canada cheap ed pills in mexico
cheap ed pills
Doctoral thesis help with thesis statement thesis data analysis
June 7, 2017: kamagra combineren kamagra jelly amazon
diflucan vs nystatin diflucan diflucan tablets over the counter how often can you take diflucan for over growth of knuckles
dapoxetine tadalafil combination priligy 30mg india where to buy dapoxetine online where can i buy priligy
Jlcfyx – tadalafil 20mg Lpprnw tzrkto
tadalafil pills https://elitadalafill.com/ tadalafil tablets
synthroid contraindications synthroid without a rx does grapefruit interfere with synthroid when to take synthroid pills
Iypayf – furosemide dosage Yeafxd uvstyz
diflucan toenail fungus generic diflucan prices diflucan safe during first trimester how long diflucan
plaquenil cheapest: buy hydroxychloroquine online – cost of plaquenil in us
http://prednisonest.com/# can i buy prednisone from canada without a script
buy zithromax without prescription online: generic zithromax – zithromax for sale usa
http://hydroxychloroquinest.com/# plaquenil 50 mg
where can i get prednisone over the counter: generic prednisone – prednisone 5 50mg tablet price
Custome essay https://customessayin.com/
best custom essay writers
https://zithromaxst.com/# zithromax buy
Najwdr – tadalafil online uk Rlixne idbnbr
http://gabapentinst.com/# can you buy neurontin over the counter
Ysnxta – price of 50mg viagra Quqgjy cehjcp
http://prednisonest.com/# prednisone over the counter australia
Persuasive essay writer essaywritera.com fake essay
writer
https://zithromaxproff.com/# zithromax online usa no prescription
zithromax price canada
http://zithromaxproff.com/# where can i buy zithromax capsules
buy zithromax online fast shipping
http://zithromaxproff.com/# zithromax 500 mg lowest price online
buy azithromycin zithromax
Ethyio – essays required for texas a m Rmzfvc zsjsii
synthroid drug interactions synthroid buy online can synthroid be cut in half what is synthroid made of
Write my essay online best essay writers write my essay 4 me
Szflkj – how to buy viagra online safely Cyonrq blascu
http://zithromaxproff.com/# zithromax 250 price
where can i get zithromax over the counter
propecia in women propecia 10 mg how much is prescription propecia propecia how long fpr shed hair to grow back
obamacare health
stromectol
buy chloramphenicol generic: order fucidin online
generic roxithromycin
How to write my paper papersonlinebox.com custom papers online
propecia experiences generic propecia finasteride 1mg what does propecia look like what are the side effects of the propecia hair growth
Wtbnjb – buy research papers cheap Biimrg jfvrvp
generic omnicef: order zithromax
noroxin tablets
prednisolone medication methylprednisolone prednisolone 15mg/5ml soln prednisolone 5mg equals how much prednisone
Kpjuav – use finasteride 5mg on people instead of dogs Ueqjwx fmqxdi
Original cialis uk brand cialis on line discount generic cialis
metformin er purchase metformin without a prescription does metformin cause high blood pressure how long does it take to get pregnant on metformin
buy prescriptions from india pharmacy: online indian pharmacies best online international pharmacies india
neurontin ip 102 best gabapentin brand can you use neurontin for tooth pain how much gabapentin for cats
indian online pharmacies review: india pharmacies shipping to usa india pharmacies online
Lviibs – cialis 20mg vs viagra 100mg Ucrkgg pmhnfx
india pharmacy without dr prescriptions: india pharmacy without dr prescriptions cheap online pharmacies from india
metformin extended release metformin online no prescription can you cut metformin in half what is the difference between metformin hcl and metformin er
Fkgxbf – stop taking finasteride 5mg Duqlzm yxrmbx
define neurontin gabapentin 100mg side effect of neurontin 300 mg how to avoid weight gain on gabapentin
india pharmacies shipping to usa: trusted india online pharmacies best online international pharmacies india
order medications online from india: online medications from india order prescription drugs from india
levitra coupon walmart india levitra 40 mg
top erectile dysfunction pills: kamagra pills levitra pills
Canada pharmacy online reviews pharmacy online prescription canada drugs online pharmacy
levitra pills: https://edpillsonline24.com/# best male erectile dysfunction pill
paxil vs citalopram paxil discount coming off paxil side effects what is paxil for
paxil nausea paxil 200 mg will paxil help you sleep what paxil looks like
best ed pills: https://edpillsonline24.com/# viagra pills
cyp2d6 and plaquenil plaquenil for rheumatoid arthritis what is side effects of plaquenil how to market rheumatologist to do plaquenil testing
cialis pills: top erectile dysfunction pills cialis pills
Qcujzv – rx sildenafil Afxylb insgyr
Pharmacy online drugstore canadian government approved pharmacies online canadian pharcharmy
viagra coupons buy viagra without prescription viagra without a prescription
discount viagra http://himpills.com buy 20 mg cialis online Ucao60t what is pc health
viagra from india: buy viagra online without prescription buy viagra without prescription