我最近使用wordpress插件在我的网站上编辑了robots.txt文件.但是,由于我这样做,谷歌似乎已从他们的搜索页面删除了我的网站.如果我能得到关于为什么会这样,以及可能的解决方案的专家意见,我将不胜感激.我最初是通过限制谷歌访问的页面来增加我的搜索排名.
这是我在wordpress中的robots.txt文件:
User-agent: *
Disallow: /cgi-bin
Disallow: /wp-admin
Disallow: /wp-includes
Disallow: /wp-content/plugins
Disallow: /wp-content/cache
Disallow: /trackback
Disallow: /feed
Disallow: /comments
Disallow: /category/*/*
Disallow: */trackback
Disallow: */feed
Disallow: */comments
Disallow: /*?*
Disallow: /*?
Allow: /wp-content/uploads
Sitemap: http://www.instant-wine-cellar.co.uk/wp-content/themes/Wineconcepts/Sitemap.xml
Run Code Online (Sandbox Code Playgroud) 我可以在终端中运行一个程序,它会吐出一个网页的输出吗?基本上我想将其输出(robots.txt)从网页重定向到txt文件.
我正在尝试读取txt文件并将其存储在NSArray中.这是我的代码,但似乎缺少一些我不知道的东西!
NSURL *url=[NSURL URLWithString:@"http://www.google.com/robots.txt"];
NSMutableArray *robots=[NSMutableArray arrayWithContentsOfURL:url];
NSLog(@"%@",robots);
Run Code Online (Sandbox Code Playgroud) 我正在使用许多无法在移动设备上正常工作的效果构建这个网站,因此我们构建了一个简单的 html 版本,当它们不支持所有效果时,我们将设备重定向到它上面。
Normal version URL: www.mysite.com/#some_page_name
Simple version URL:www.mysite.com/static.php?p=some_page_name
Run Code Online (Sandbox Code Playgroud)
问题是我们不希望谷歌、必应和雅虎在搜索结果中提供简单版本的 URL,我们总是希望人们登陆网站的正常版本。
是否可以用 Apache、PHP 或 JS 告诉搜索引擎机器人忽略所有以 static.php 开头的 URL?
我尝试使用file_exists(URL/robots.txt)来查看该文件是否存在于随机选择的网站上,并得到错误的回复;
如何检查robots.txt文件是否存在?
在我检查之前,我不想开始下载.
使用fopen()可以解决问题吗?因为:成功时返回文件指针资源,错误时返回FALSE.
我想我可以把这样的东西:
$f=@fopen($url,"r");
if($f) ...
Run Code Online (Sandbox Code Playgroud)
我的代码:
http://www1.macys.com/robots.txt 也许它不存在 http://www.intend.ro/robots.txt 也许它不存在 http://www.emag.ro/robots.txt 也许它不是那里 http://www1.bloomingdales.com/robots.txt 也许它不存在
try {
if (file_exists($file))
{
echo 'exists'.PHP_EOL;
$curl_tool = new CurlTool();
$content = $curl_tool->fetchContent($file);
//if the file exists on local disk, delete it
if (file_exists(CRAWLER_FILES . 'robots_' . $website_id . '.txt'))
unlink(CRAWLER_FILES . 'robots_' . $website . '.txt');
echo CRAWLER_FILES . 'robots_' . $website_id . '.txt', $content . PHP_EOL;
file_put_contents(CRAWLER_FILES . 'robots_' . $website_id . '.txt', $content);
}
else
{
echo 'maybe it\'s …
Run Code Online (Sandbox Code Playgroud) 我遇到问题,try_files似乎没有将不存在的文件的请求传递给最后指定的值,在我的例子中是index.php.我正在使用Wordpress和我使用的XML Sitemap生成器插件创建虚拟XML文件和由Wordpress处理的虚拟robots.txt.不幸的是,try_files似乎没有将这些文件的请求传递给Wordpress.
这是我的服务器配置:
server {
## Web domain
server_name christiaanconover.com;
## Site root
root /var/www/christiaanconover.com;
## Index
index index.php index.htm;
## Common Wordpress configuration
include wp.conf;
## Include PHP configuration
include php.conf;
## Gzip Compression
include gzip.conf;
## Include W3TC configuration
include /var/www/w3tc/christiaanconover.com;
}
Run Code Online (Sandbox Code Playgroud)
我在这台服务器上运行多个单独的Wordpress站点,所以为了节省时间,我创建了一个文件wp.conf,其中包含Wordpress的所有常用配置元素.这是wp.conf的内容:
location / {
## Prevent PHP files from being served as static assets, and fall back to index.php if file does not exist
try_files $uri $uri/ /index.php?$args;
## If a file exists, serve it directly …
Run Code Online (Sandbox Code Playgroud) 我的 sitemap.xml 和 robots.txt 之间似乎有冲突
我网站上的所有图像都存储在文件夹 /pubstore 中,当谷歌抓取该文件夹时,它什么也没找到,因为我不包括该文件夹中的文件列表。
这反过来会在谷歌搜索控制台中产生数百个 404 错误。
我决定做的是通过添加以下内容来阻止谷歌抓取文件夹:
Disallow: '/pubstore/'
Run Code Online (Sandbox Code Playgroud)
现在发生的是该文件夹中或该文件夹中子目录中的文件被谷歌阻止,因此谷歌没有索引我的图像。
所以一个示例场景,
我有一个使用图像 /pubstore/12345/image.jpg 的页面
Google 无法获取它,因为 /pubstore 已被阻止。
我的最终结果是我希望实际文件是可抓取的,但不是文件夹或其子目录。
允许:
/pubstore/file.jpg
/pubstore/1234/file.jpg
/pubstore/1234/543/file.jpg
/pubstore/1234/543/132/file.jpg
Run Code Online (Sandbox Code Playgroud)
不允许:
/pubstore/
/pubstore/1234/
/pubstore/1234/543/
/pubstore/1234/543/132/
Run Code Online (Sandbox Code Playgroud)
如何做到这一点?
请告诉我如何将以下机器人(txt)代码转换为 Python 代码。机器人代码。
*** Settings ***
Library OperatingSystem
*** Keywords ***
nik_key_1
[Arguments] ${arg1_str}
log to console ${arg1_str}
*** Variables ***
${var1} "variable1"
*** Test Cases ***
First Test Case
${output}= run "hostname"
log to console ${output}
${str1}= catenate "nikhil" "gupta"
nik_key_1 "NikArg1"
log to console ${var1}
log to console ${str1}
Run Code Online (Sandbox Code Playgroud)
以下是我尝试的代码:
from robot.api import TestSuite
from robot.running.model import Keyword
from robot.libraries.BuiltIn import BuiltIn
from robot.api.deco import keyword
bi = BuiltIn()
@keyword(name='nik_key_1')
def nik_key_1(username):
bi.log_to_console(message=username,stream='STDOUT',no_newline=False)
suite = TestSuite('Activate Skynet')
suite.resource.imports.library("OperatingSystem") …
Run Code Online (Sandbox Code Playgroud) 使用 RobotFramework,
我正在尝试使用 FOR 循环检索 Webelements 标签。
${temp}= Get WebElements xpath=//*[@class='ui-grid-canvas']
Set Global Variable ${temp}
${as} Get Element Count xpath=//*[@class='ui-grid-canvas']
: FOR ${ELEMENT} IN ${temp}
\ ${as}= Get Text ${ELEMENT}
Run Code Online (Sandbox Code Playgroud)
我在 FOR 循环中出错。请纠正我。
AttributeError: 'list' object has no attribute 'startswith'
Run Code Online (Sandbox Code Playgroud) robots.txt ×10
php ×3
seo ×3
wordpress ×2
apache ×1
browser ×1
javascript ×1
linux ×1
nginx ×1
nsarray ×1
objective-c ×1
plugins ×1
python ×1
selenium ×1
sitemap.xml ×1
terminal ×1