这是我正在爬行的网站。一开始我没有问题,但是后来我遇到了这个错误。
[scrapy] DEBUG: Redirecting (meta refresh) to <GET https://www.propertyguru.com.my/distil_r_captcha.html?requestId=9f8ba25c-3673-40d3-bfe2-6e01460be915&httpReferrer=%2Fproperty-for-rent%2F1> from <GET https://www.propertyguru.com.my/property-for-rent/1>
Run Code Online (Sandbox Code Playgroud)
网站知道我是机器人,并将我重定向到带有验证码的页面。我认为handle_httpstatus_listordont_redirect不起作用,因为重定向不是通过 http 状态代码完成的。这是我的爬虫代码。有什么办法可以阻止这种重定向吗?
class MySpider(CrawlSpider):
name = 'myspider'
start_urls = [
'https://www.propertyguru.com.my/property-for-rent/1',
]
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36'
}
meta = {
'dont_redirect': True
}
def parse(self, response):
items = response.css('div.header-container h3.ellipsis a.nav-link::attr(href)').getall()
if items:
for item in items:
if item.startswith('/property-listing/'):
yield scrapy.Request(
url='https://www.propertyguru.com.my{}'.format(item),
method='GET',
headers=self.headers,
meta=self.meta,
callback=self.parse_items
)
def parse_items(self, response): …Run Code Online (Sandbox Code Playgroud) 我在 viewpager 中有 3 个主要片段,它们有几个按钮。我希望每个按钮导航到另一个片段,后退按钮返回主片段。我试图添加片段事务,但它不起作用。我在这里做错了什么?
这是主要片段之一
public class OneFragment extends Fragment implements View.OnClickListener{
public OneFragment() {
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_one, container, false);
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.aButton:
FragmentManager manager = getFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.replace(R.id.fragment_one, AFragment.newInstance());
transaction.commit();
break;
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是我要导航的片段
public class AFragment extends Fragment{
public AFragment() {
}
public static AFragment newInstance() { …Run Code Online (Sandbox Code Playgroud) I'm trying to use different weights for my model and I need those weights add up to 1 like this;
def func(length):
return ['a list of numbers add up to 1 with given length']
Run Code Online (Sandbox Code Playgroud)
func(4) returns [0.1, 0.2, 0.3, 0.4]
The numbers should be linearly spaced and they should not start from 0. Is there any way to achieve this with numpy or scipy?
我正在制作一个简单的转换器应用程序.尝试转换输入并在下面的EditTexts中显示它,但我的ScrollView不起作用.(字面意思什么也没做)我使用ConstraintLayout作为root,我在其中有LinearLayout,它是ScrollView的根.
那么,我在这里错过了什么?
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="gns.converter.LengthConversion">
<Spinner
android:id="@+id/spinnerTo"
android:layout_width="120dp"
android:entries="@array/spinnerLengthItems"
android:layout_height="wrap_content"
app:layout_constraintLeft_toRightOf="@+id/textFrom"
android:layout_marginLeft="42dp"
app:layout_constraintBaseline_toBaselineOf="@+id/textFrom"
android:layout_marginStart="42dp" />
<EditText
android:id="@+id/textFrom"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number"
android:textSize="20sp"
android:hint="(From) 0"
android:gravity="right"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="44dp"
android:layout_marginLeft="16dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginStart="16dp" />
<Button
android:id="@+id/buttonConvert"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="78dp"
android:layout_marginTop="13dp"
android:text="CONVERT"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textFrom"
android:layout_marginStart="78dp" />
<Button
android:id="@+id/buttonClear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="42dp"
android:layout_marginTop="23dp"
android:text="CLEAR"
app:layout_constraintLeft_toRightOf="@+id/buttonConvert"
app:layout_constraintTop_toBottomOf="@+id/spinnerTo"
android:layout_marginStart="42dp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="495dp"
android:orientation="horizontal"
android:layout_marginRight="8dp"
android:background="#e40707"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginTop="30dp"
app:layout_constraintTop_toBottomOf="@+id/buttonConvert"
app:layout_constraintHorizontal_bias="0.0">
<ScrollView
android:layout_width="match_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"> …Run Code Online (Sandbox Code Playgroud)