返回列表 发帖

【完结】求网页信息抓取+150元

本帖最后由 lxh623 于 2021-10-10 17:40 编辑

两个网站。各150元。
第一,https://www.km.com/tv/---.html
全部电视剧。名称前面加TTT。
图片地址
【概览】(添加文字)
剧情介绍之前的内容。包括导演、得分等七八项。剧情最后要展开。这里的演员表不要,因为下面有。
【分集剧情】
【演员表】每一个演员人名加ZZZ。
【人物介绍】
【幕后信息】左右栏目,麻烦转行。
第二、https://www.tvsou.com/class/dianshiju/
全部电视剧。名称前面加TTT。
图片地址
【概览】(添加文字)
这里的演员表不要,因为下面有。
【分集剧情】
剧情介绍+分集剧情
【演员表】每一个演员人名加ZZZ。

也可以我事先得到所有电视剧链接。按照文本去打开。

不知道会不会拦截,但愿没有。
我不会用于建网。

谢谢!


已成功获取

TOP

本帖最后由 a20150604 于 2021-9-30 12:48 编辑

以下为单页获取演示, 可让代码自动逐页全部获取
演示为此2页
https://www.km.com/tv/-----13.html
https://www.km.com/tv/-----14.html

TOP

要采集的信息那么多,才100元,不值得写
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

本帖最后由 slimay 于 2021-9-30 14:51 编辑

请到 http://cmd1152.ys168.com/  文件区   下载 "lxh623已经提取好的资料.zip"  
附赠 提取工具, 赠三种数据格式 ,txt, html, excel表格格式. 均是提取好的全部数据, 直接使用.无需加工
..   http://cmd1152.ys168.com/  文件区   下载 "lxh623已经提取好的资料.zip"
七猫影视-提取.html
七猫影视-提取.xls
定制说明.txt
搜视网-提取.html
搜视网-提取.xls
文本格式
新站到-提取.html
新站到-提取.xls
附赠提取工具COPY
提取脚本,网址随便改, 理论上可提取任何网站
@echo off
REM 设置提取网址
set "url=https://www.tvsou.com/class/dianshiju/--"
REM 设置网页数量
set "num=100"
REM 开始提起网页
for /l %%a in (1,1,%num%) do (
echo;正在下载 第 %%a 个页面
curl  "%url%--%%a"  > home\%%a.txt
echo;正在转码 第 %%a 个页面
wincp    home\%%a.txt  -o ansi\N_%%a.txt -f 65001 -t 936
)
REM 直接输出提取后的信息
(
for /l %%a in (1,1,%num%) do (
zq    ansi\N_%%a.txt  
)
) > out.html
pauseCOPY
1

评分人数

TOP

回复 3# a20150604


    我擦,你真牛b

TOP

5楼只有标题,而且放弃了。
欢迎大家继续。

TOP

#&cls&@cd /d "%~dp0" & powershell -c "Get-Content '%~0' | Select-Object -Skip 1 | Out-String | Invoke-Expression" &pause&exit
cls
#whr
$whr = New-Object -ComObject 'WinHttp.WinHttpRequest.5.1'
#函数 获取一页列表
function Get-PageList($page){
    $url = 'https://www.km.com/tv/-----{0}.html' -f $page
    $whr.Open('GET',$url,$false)
    $whr.Send()
    if($whr.Status -eq 200){
        $txt = $whr.ResponseText
        $whr.Abort()
        $pattern = '(?<=<div class="filter_res_image scale_image_container">\s+<a href=").*?(?=")'
        [regex]::Matches($txt,$pattern) | foreach {
            if($_.Value -match '/(\d+).html$'){
                $Matches[1]
            }
        }
    }
}
#函数 获取主要信息
function Get-MainInfo($key){
    #主要信息界面
    $url = 'https://www.km.com/tv/{0}.html' -f $key
    $whr.Open('GET',$url,$false)
    $whr.Send()
    $txt = $whr.ResponseText
    $whr.Abort()
    #标题
    $pattern = '(?s)<div class="inside-title.*?>.*?>(.*?)<'
    if($txt -match $pattern){
        '名称: TTT' + $Matches[1]
        Write-Host ('解析电视剧: ' + $Matches[1])
    }
    #图片地址
    $pattern = '(?s)<div class="video_poster.*?">.*?<img src="(.*?)"'
    if($txt -match $pattern){
        '图片地址: ''https:' + $Matches[1]
    }
    #概览
    "`r`n【概览】"
    $pattern = '(?s)mr20">(.*?)<a class="unfold"'
    if($txt -match $pattern){
        $t = $Matches[1] -replace '(?s)<script>.*?</script>','' -replace '<.*?>','' -replace '\s{2,}',''
        $t -replace '(导演:)|(主演:)|(地区/类型:)|(剧情集数:)|(播出时间:)|(在线观看网站:)|(别名:)|(片长:)',("`r`n" + '$0')
    }
    #分数
    $pattern = '(?s)<p class="score_num.*?>.*?>(.*?)<'
    if($txt -match $pattern){
        '综合评分: ' + $Matches[1]
    }
    #幕后信息
    "`r`n【幕后信息】"
    $pattern = '(?s)幕后信息</div>(.*?)<a class="intro_fold'
    if($txt -match $pattern){
        $Matches[1] -replace '<.*?>','' -replace '\s{2,}','' -replace '(编剧:)|(制片人:)|(TV首播时间:)|(在线播放平台:)|(出品公司:)|《',("`r`n" + '$0')
    }
    #演员表
   "`r`n【演员表】"
    $url = 'https://www.km.com/tv/yanyuan/{0}.html' -f $key
    $whr.Open('GET',$url,$false)
    $whr.Send()
    $txt = $whr.ResponseText
    $whr.Abort()
    $pattern = '(?s)<div class="actor-list-detail same_col">.*?<div class="actor-works same_col_bottom">'
    [regex]::Matches($txt,$pattern) | foreach {
        'ZZZ' + ($_.Value -replace '<.*?>','' -replace '\s{2,}','' -replace '饰演'," 饰演 ")
    }
    #人物介绍
"`r`n【人物介绍】"
    $url = 'https://www.km.com/tv/role/{0}.html' -f $key
    $whr.Open('GET',$url,$false)
    $whr.Send()
    $txt = $whr.ResponseText
    $whr.Abort()
    $pattern = '(?s)<div class="role-name">.*?<div class="role-intro-js">'
    [regex]::Matches($txt,$pattern) | foreach {
        $_.Value -replace '<.*?>','' -replace '\s{2,}','' -replace '演员',' 演员' -replace '-->简介:',"-->简介:`r`n`t"
    }
}
#函数 一页数据保存为一个文件
function Save-PageInfo($page){
    #如果本页已解析,则跳过
    $f = 'page_{0:000}.txt' -f $page
    if([System.IO.File]::Exists($f)){
        '第{0}页已解析,跳过...' -f $page
        return;
    }
    #开始解析
    &{
        Get-PageList -page 1 | foreach {
            Get-MainInfo -key $_
            '----------------------------------'
        }
    } | Out-File $f
}
#解析并保存第一页数据
Save-PageInfo -page 1COPY
1

评分人数

TOP

本帖最后由 lxh623 于 2021-10-4 16:01 编辑

回复 8# went
如果我把所有电视剧网址写入文本a,再一个一个获取,可能更好。
【概览】里面的“主演”不要了,因为后面有演员。
【分集剧情】包括剧情介绍(展开)和每一集剧情,暂时没有抓取。
谢谢!

有些演员那里没有转行。
比如,ZZZ车梓茗 饰演 :齐贵田玲 饰演 牛兰花张宛庭 饰演 孙桂琴闫锐 饰演 马志刚王超 饰演 李天洋

TOP

回复 9# lxh623


    地址你保存的这种格式?
https://www.km.com/tv/98324.html
https://www.km.com/tv/96830.html
https://www.km.com/tv/56848.html
https://www.km.com/tv/97869.html
https://www.km.com/tv/94010.html
https://www.km.com/tv/97924.html
https://www.km.com/tv/96880.html
https://www.km.com/tv/99023.html
https://www.km.com/tv/58624.html
https://www.km.com/tv/95650.html
https://www.km.com/tv/96842.html
https://www.km.com/tv/97604.html
https://www.km.com/tv/94180.html
https://www.km.com/tv/99840.html
https://www.km.com/tv/93130.html
https://www.km.com/tv/57571.html
https://www.km.com/tv/98348.html
https://www.km.com/tv/97183.html
https://www.km.com/tv/99770.html
https://www.km.com/tv/61631.html
https://www.km.com/tv/97788.html
https://www.km.com/tv/95876.html
https://www.km.com/tv/97131.html
https://www.km.com/tv/58078.htmlCOPY
1

评分人数

TOP

本帖最后由 went 于 2021-10-4 18:34 编辑

url保存为楼上格式,a.txt
#变量设置
$cur_file = 'pass.txt' #保存已读取的个数
$url_file = 'a.txt'    #URL列表文件
$out_file = 'info.txt' #输出信息文件
#&cls&@cd /d "%~dp0" & powershell -c "Get-Content '%~0' | Select-Object -Skip 1 | Out-String | Invoke-Expression" &pause&exit
cls
#whr
$whr = New-Object -ComObject 'WinHttp.WinHttpRequest.5.1'
#函数 获取主要信息
function Get-MainInfo($key){
    #主要信息界面
    $url = 'https://www.km.com/tv/{0}.html' -f $key
    $whr.Open('GET',$url,$false)
    $whr.Send()
    $txt = $whr.ResponseText
    $whr.Abort()
    #标题
    $pattern = '(?s)<div class="inside-title.*?>.*?>(.*?)<'
    if($txt -match $pattern){
        '名称: TTT' + $Matches[1]
        Write-Host ('解析电视剧: ' + $Matches[1])
    }
    #图片地址
    $pattern = '(?s)<div class="video_poster.*?">.*?<img src="(.*?)"'
    if($txt -match $pattern){
        '图片地址: https:' + $Matches[1]
    }
    #概览
    "`r`n【概览】"
    $pattern = '(?s)mr20">(.*?)<a class="unfold"'
    if($txt -match $pattern){
        $t = $Matches[1] -replace '(?s)<script>.*?</script>','' -replace '<.*?>','' -replace '\s{2,}',''
        $t -replace '(导演:)|(主演:)|(地区/类型:)|(剧情集数:)|(播出时间:)|(在线观看网站:)|(别名:)|(片长:)',("`r`n" + '$0') -replace "主演:.*?`r`n",''
    }
    #分数
    $pattern = '(?s)<p class="score_num.*?>.*?>(.*?)<'
    if($txt -match $pattern){
        '综合评分: ' + $Matches[1]
    }
    #获取剧情介绍内容和总集数
    $plot_main = ''
    $pattern = '剧情介绍:.*?>(.*?)<'
    if($txt -match $pattern){
        $plot_main = $Matches[1]
    }
    $pattern = '>\(全部&nbsp;(\d+)<'
    if($txt -match $pattern){
        $part = $Matches[1]
    }
   
    #幕后信息
    "`r`n【幕后信息】"
    $pattern = '(?s)幕后信息</div>(.*?)<a class="intro_fold'
    if($txt -match $pattern){
        $Matches[1] -replace '<.*?>','' -replace '\s{2,}','' -replace '(编剧:)|(制片人:)|(TV首播时间:)|(在线播放平台:)|(出品公司:)|《',("`r`n" + '$0')
    }
    #演员表
   "`r`n【演员表】"
    $url = 'https://www.km.com/tv/yanyuan/{0}.html' -f $key
    $whr.Open('GET',$url,$false)
    $whr.Send()
    $txt = $whr.ResponseText
    $whr.Abort()
    $pattern = '(?s)<div class="actor-list-detail same_col">.*?<div class="actor-list-detail same_col">'
    [regex]::Matches($txt,$pattern) | foreach {
        if($_.Value.Contains('<em>饰</em><em>演</em>')){
            'ZZZ' + $_.Value -replace '<.*?>|\s{2,}',''-replace '饰演'," 饰演 " -replace '最近作品:.*$',''
        }
    }
    #人物介绍
   "`r`n【人物介绍】"
    $url = 'https://www.km.com/tv/role/{0}.html' -f $key
    $whr.Open('GET',$url,$false)
    $whr.Send()
    $txt = $whr.ResponseText
    $whr.Abort()
    $pattern = '(?s)<div class="role-name">.*?<div class="role-intro-js">'
    [regex]::Matches($txt,$pattern) | foreach {
        $_.Value -replace '<.*?>','' -replace '\s{2,}','' -replace '演员',' 演员' -replace '-->简介:',"-->简介:`r`n`t"
    }
    #解析分集剧情
    Get-PartInfo -key $key -title $plot_main -max $part
    '-----------------------------------------------------------------------------'
}
#函数 解析分集剧情
function Get-PartInfo($key,$title,$max){
"`r`n【分集剧情】"
    "`t剧情介绍`n`t`t" + $title
    for($i = 1; $i -le $max; $i++){
        "`t第{0}集`t`t" -f $i
        $url = 'https://www.km.com/tv/{0}/2_{1}.html' -f $key,$i
        #读取网页内容
        $whr.Open('GET',$url,$false)
        $whr.Send()
        $txt = $whr.ResponseText
        $whr.Abort()
        #解析剧情内容
        $pattern = '(?s)<div class="article-content">.*?</div>'
        if($txt -match $pattern){
            "`t`t" + ($Matches[0] -replace '<.*?>','' -replace '\s{2,}',' ').Trim()
        }
    }
}
#变量设置
$cur_file = 'pass.txt' #保存已读取的个数
$url_file = 'a.txt'    #URL列表文件
$out_file = 'info.txt' #输出信息文件
#读取已经解析的个数
$cur = 0
if([System.IO.File]::Exists($cur_file)){
    $line = Get-Content $cur_file | Select-Object -First 1
    if($line -match '\d+'){
        $cur = [int]$line
    }
}
        Write-Host ('上次解析个数: {0}' -f $cur)
#读取url并解析内容
Get-Content $url_file | Select-Object -Skip $cur | foreach {
    if($_ -match 'https://www.km.com/tv/(\d+).html'){
        #解析内容
        Get-MainInfo -key $Matches[1] | Out-File $out_file -Append
        #保存当前进度
        ++$cur
        Out-File -InputObject $cur -FilePath $cur_file
    }
}COPY
1

评分人数

TOP

本帖最后由 lxh623 于 2021-10-4 18:32 编辑

回复 11# went
麻烦增加【人物介绍】几个字。
麻烦查收。

TOP

回复 12# lxh623


    加上了

TOP

麻烦做一下补充批处理。50元。
文本b,写入名字,一行一个。到https://www.tvmao.com/搜索,得到链接,打开,获取分集剧情。
格式
TTT
第1集
........
第2集
.......


谢谢!

TOP

本帖最后由 went 于 2021-10-5 15:54 编辑

回复 14# lxh623


    b.txt保存电视剧名称,ansi编码
夺金
光芒
一生一世
叛逆者
火红年华
国子监来了个女弟子
君九龄
周生如故
乔家的儿女
扫黑风暴
程序员那么可爱
功勋
夺金战
当爱情遇上科学家
双刺
燃烧大地
启航:当风起时
你好检察官
我哥我嫂
理想之城COPY
test.bat脚本文件,ansi编码
#&cls&@cd /d "%~dp0" & powershell -c "Get-Content '%~0' | Select-Object -Skip 1 | Out-String | Invoke-Expression" &pause&exit
cls
#whr
$whr = New-Object -ComObject 'WinHttp.WinHttpRequest.5.1'
#设置请求头
function Set-RequestHeader($whr){
    $whr.SetRequestHeader('User-Agent','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36 Edg/94.0.992.38');
    $whr.SetRequestHeader('Host','www.tvmao.com')
    $whr.SetRequestHeader('Connection','Keep-Alive')
}
#函数 根据关键字获取url链接
function Get-Url($kw){
    $url = 'https://www.tvmao.com/servlet/queryobject?type=all&term=' + [System.Net.WebUtility]::UrlEncode($kw)
    $whr.Open('GET',$url,$false)
    Set-RequestHeader -whr $whr
    $whr.Send()
    $txt = $whr.ResponseText
    $whr.Abort()
    if($txt -match '"url":"(.+?)"'){
        return 'https://www.tvmao.com' + $Matches[1] + '/episode'
    }
    return $null
}
#函数 根据url链接获取所有分集的链接
function Get-PartUrlList($url){
    if($url -eq $null){
        return $null
    }
    $whr.Open('GET',$url,$false)
    Set-RequestHeader -whr $whr
    $whr.Send()
    $txt = $whr.ResponseText
    $whr.Abort()
    $pattern = '<div class="epipage.*?>.*?</div>'
    if($txt -match $pattern){
        $pattern = '(?s)href="(.*?)"'
        return &{
            [regex]::Matches($Matches[0],$pattern) | foreach {
                'https://www.tvmao.com' + $_.Groups[1].Value
            }
        }
    }
    return $null
}
#函数 根据分集url获取分集剧情
function Get-PartInfo($part_url){
    if($part_url -match '-(\d+)$'){
        Write-Host ('解析第{0}集 {1}' -f $Matches[1],$part_url)
        '第{0}集' -f $Matches[1]
    } else {
return;
}
    $whr.Open('GET',$part_url,$false)
    Set-RequestHeader -whr $whr
    $whr.Send()
    $txt = $whr.ResponseText
    $whr.Abort()
    $pattern = '(?s)<article class=".*?epi_c">.*?</article>'
    if($txt -match $pattern){
        $Matches[0] -replace '(?s)<.*?>','' -replace '(?s)\(.*?转载许可\).*$',''
    }
}
#变量设置
$cur_file = 'pass.txt' #保存已读取的个数
$list_file = 'b.txt'   #电视剧名称列表文件
$out_file = 'info.txt' #输出信息文件
#读取已经解析的个数
$cur = 0
if([System.IO.File]::Exists($cur_file)){
    $line = Get-Content $cur_file | Select-Object -First 1
    if($line -match '\d+'){
        $cur = [int]$line
    }
}
Write-Host ('上次解析个数: {0}' -f $cur)
#读取电视剧名称并解析内容
Get-Content $list_file | Select-Object -Skip $cur | foreach {
    $url = Get-Url -kw $_.Trim()
    if($url -ne $null){
Write-Host ('正在解析 {0} {1}' -f $_,$url)
Write-Host '---'
        $info = &{
            '名称: {0}' -f $_.Trim()
            Get-PartUrlList -url $url | foreach {
                Get-PartInfo -part_url $_
            }
'--------------------------------------------------'
        }
        Out-File -FilePath $out_file -InputObject $info -Append
        Write-Host '--------------------------------------------------'
    }
    ++$cur
    Out-File -FilePath $cur_file -InputObject $cur
}COPY
1

评分人数

TOP

返回列表